Sunday, March 11, 2012

Abstract types should not have public constructors

Microsoft's heading is a bit imprecise. Public will work , though. Private wont (though that has nothing to do with being abstract):

   class Program
    {
        static void Main(string[] args)
        {
            test2 t = new test2(); 
        }
    }

    public abstract class test
    {
       private  test()
        {
        }
    }


    public class test2 : test
    {
        public test2()
        {
        }
    }

No comments:

Post a Comment