0

I try to move my class into a class library project, but I got errors on isClass property in my code. Any help would be appreciated.

code:

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:

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?)
Nugraha
  • 15
  • 2
  • 8
  • 2
    see http://stackoverflow.com/questions/1827425/how-to-check-programatically-if-a-type-is-a-struct-or-a-class – Muckeypuck Aug 28 '16 at 15:03
  • The type of project matters a lot. Crystal ball says that you are targeting .NETCore, use the TypeInfo class instead. Or you picked the wrong project template to get started, "Class library (Package)" has a particularly lousy name. – Hans Passant Aug 28 '16 at 17:02

0 Answers0