-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Labels
Description
Original:
using System;
internal class Program
{
static void Main(string[] args)
{
My my = new My();
switch (my)
{
case 1:
Console.WriteLine(1);
break;
case 2:
Console.WriteLine(2);
break;
case 3:
Console.WriteLine(3);
break;
}
Console.WriteLine("Hello World!");
}
}
public class My
{
public static implicit operator int(My my)
{
return 0;
}
}ILSpy
private static void Main(string[] args)
{
My my = new My();
switch (my)
{
case 1L: // Compiler Error CS0266, why is it a long?
Console.WriteLine(1);
break;
case 2L:
Console.WriteLine(2);
break;
case 3L:
Console.WriteLine(3);
break;
}
Console.WriteLine("Hello World!");
}