我尝试将我的类移动到类库项目中,但是我的代码中的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?)