Is it possible to use the switch when comparing Classes in a generic method? Example:
switch (typeof(T))
{
case typeof(Class1):
// ...
break;
case typeof(Class2):
// ...
break;
default:
break;
}
The idea is not to use the name but the Class object. At moment I'm using:
if (typeof(T) == typeof(Class1))
{
// ...
}
else if (typeof(T) == typeof(Class2))
{
// ...
}
For simplicity, it would be good to use the switch.