[Mono-dev] C# compiler (mcs) bug with private constructors ?

Denis ERCHOFF d_erchoff at hotmail.com
Thu Mar 23 14:40:27 EST 2006


Hi all,

I have a problem with the mcs compiler.
    I defined a test class with a private default constructor ( see the 
following code ). When i create a new object with this class, using the 
private constructor, mcs accept it !

    Visual Studio raise a compilation error ( and i think that it must 
be the right way ).


I am using mono 1.1.13.4 with Windows XP sp2.


Here is a simple test class :

namespace Test
{

    public class TestClass
    {
       public static TestClass instance = new TestClass();
        public void Echo()
        {
            System.Console.WriteLine("ECHO");
        }

        private TestClass() : base()
        {
        }
    }

    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    class Class1
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            TestClasstest = new TestClass();
        }
    }
}



More information about the Mono-devel-list mailing list