Consider the following code snippet:
using System;
enum E { A, }
struct T
{
public static explicit operator T(int i) { return new T(); }
public static void Foo()
{
E e = 0;
IntPtr ptr = (IntPtr)e; // case 1: compiles fine
T t = (T)e; // case 2: gives an error in correspondence with the specs
}
}
Microsoft C# compiler gives an error in case 2 (which follows the specs). In
case 1 the code compiles fine.
Does the compiler follow the specs in case 1? If so, where is the
description of that case in the specs?
I used C# compiler from VS 2003 and 2.0 November preview.
Thanks,
andy