none
Why does Type.IsAbstract return true when reflecting on a static class RRS feed

  • Question

  • For example...

    static class A { }
    
    class Program
    {
        static void Main(string[] args)
        {
            Type t = typeof(A);
            Console.WriteLine(t.IsAbstract);  // True
        }
    }


    Wednesday, March 9, 2016 10:50 AM

Answers

  • The runtime has no notion of static classes. The C# compiler marks such classes as abstract to prevent instantiation.
    • Marked as answer by mahbouni Wednesday, March 9, 2016 1:54 PM
    Wednesday, March 9, 2016 11:50 AM
    Moderator