ILSpy
ILSpy copied to clipboard
Improve pattern match for generic
static void Test<T>(T a)
{
if (a is int x)
Console.WriteLine(x);
}
ILSpy:
private static void Test<T>(T a)
{
if (a is int)
{
object obj = a;
int x = (int)((obj is int) ? obj : null);
if (true)
{
Console.WriteLine(x);
}
}
}