X
Xiaotian Guo
Hi,
I got compilation error while compiling following code, but according
to C# language spec 1.2 (section 6.4.3) , the code should compile. what
makes it more interesting is that, if I swap the order these 2 operators
appear in class SB, the code will compile without a problem.
Is this a bug in C# compiler? I am using
Microsoft (R) Visual C# .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
Thanks!
//----------- code starts
using System;
class SB
{
public static implicit operator TD(SB src)
{
Console.WriteLine("TD");
return new TD();
}
public static implicit operator T(SB src)
{
Console.WriteLine("T");
return new T();
}
}
class S: SB
{
}
class T
{
}
class TD : T
{
}
public class MyClass
{
static void Main()
{
S s = new S();
T t = s;
}
}
I got compilation error while compiling following code, but according
to C# language spec 1.2 (section 6.4.3) , the code should compile. what
makes it more interesting is that, if I swap the order these 2 operators
appear in class SB, the code will compile without a problem.
Is this a bug in C# compiler? I am using
Microsoft (R) Visual C# .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
Thanks!
//----------- code starts
using System;
class SB
{
public static implicit operator TD(SB src)
{
Console.WriteLine("TD");
return new TD();
}
public static implicit operator T(SB src)
{
Console.WriteLine("T");
return new T();
}
}
class S: SB
{
}
class T
{
}
class TD : T
{
}
public class MyClass
{
static void Main()
{
S s = new S();
T t = s;
}
}