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

Gert Driesen gert.driesen at telenet.be
Thu Mar 23 14:47:19 EST 2006


----- Original Message ----- 
From: "Denis ERCHOFF" <d_erchoff at hotmail.com>
To: <mono-devel-list at lists.ximian.com>
Sent: Thursday, March 23, 2006 8:40 PM
Subject: [Mono-dev] C# compiler (mcs) bug with private constructors ?


> 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();
>         }
>     }
> }

You probably ran into this bug:

http://bugzilla.ximian.com/show_bug.cgi?id=75813

Gert



More information about the Mono-devel-list mailing list