G
Guest
Hi all,
I suspect a CLR Bug.
Please look like this code fragment !
My question is: why 0 (zero) is a special value in CLR ?!
Thanks all.
Code:
using System;
namespace CLR_Bug
{
class MainClass
{
[STAThread]
static void Main(string[] args)
{
TestClass mytestclass0=new TestClass(0); //Constructor with
SimpleEnum was called !
TestClass mytestclass1=new TestClass(1); //Constructor with object
was called !
TestClass mytestclassneg1=new TestClass(-1); //Constructor with object
was called !
TestClass mytestclass1000=new TestClass(1000);//Constructor with object
was called !
TestClass mytestclassStr=new TestClass("a"); //Constructor with object
was called !
Console.WriteLine("Why this behaviour ?!");
Console.ReadLine();
//Why 0 is a special value ?
}
}
class TestClass
{
public enum SimpleEnum { Red = 0, Blue = 1, Yellow = 2 }
public TestClass(SimpleEnum se) {
Console.WriteLine("Constructor with SimpleEnum was called !");
}
public TestClass(object obj) {
Console.WriteLine("Constructor with object was called !");
}
}
}
I suspect a CLR Bug.
Please look like this code fragment !
My question is: why 0 (zero) is a special value in CLR ?!
Thanks all.
Code:
using System;
namespace CLR_Bug
{
class MainClass
{
[STAThread]
static void Main(string[] args)
{
TestClass mytestclass0=new TestClass(0); //Constructor with
SimpleEnum was called !
TestClass mytestclass1=new TestClass(1); //Constructor with object
was called !
TestClass mytestclassneg1=new TestClass(-1); //Constructor with object
was called !
TestClass mytestclass1000=new TestClass(1000);//Constructor with object
was called !
TestClass mytestclassStr=new TestClass("a"); //Constructor with object
was called !
Console.WriteLine("Why this behaviour ?!");
Console.ReadLine();
//Why 0 is a special value ?
}
}
class TestClass
{
public enum SimpleEnum { Red = 0, Blue = 1, Yellow = 2 }
public TestClass(SimpleEnum se) {
Console.WriteLine("Constructor with SimpleEnum was called !");
}
public TestClass(object obj) {
Console.WriteLine("Constructor with object was called !");
}
}
}