类库项目中的C#无法识别isclass

时间:2016-08-28 14:43:42

标签: c# visual-studio

我尝试将我的类移动到类库项目中,但是我的代码中的isClass属性出错了。任何帮助将不胜感激。

代码:

using System;
using System.Reflection;

public  class MyDemoClass
{
}

public class MyTypeClass
{
    public static void Main(string[] args)
    {
        try
        {
            Type  myType = typeof(MyDemoClass);
            // Get and display the 'IsClass' property of the 'MyDemoClass' instance.
            Console.WriteLine("\nIs the specified type a class? {0}.", myType.IsClass); 
        }
        catch(Exception e)
        {
            Console.WriteLine("\nAn exception occurred: {0}." ,e.Message);
        }
    }
}

错误:

Error   CS1061  'Type' does not contain a definition for 'isClass' and no extension method 'isClass' accepting a first argument of type 'Type' could be found (are you missing a using directive or an assembly reference?)

0 个答案:

没有答案