My code is as follows:
public static void Output<T>(IEnumerable<T> dataSource) where T : class
{
dataSourceName = (typeof(T).Name);
switch (dataSourceName)
{
case (string)typeof(CustomerDetails).Name.ToString(); :
var t = 123;
break;
default:
Console.WriteLine("Test");
}
}
But this is not working. The case statement is giving me an error saying that a constant variable is expected. Please help guys thank you!
See C# switch statement limitations - why?
Basically Switches cannot have evaluated statements in the case statement. They must be statically evaluated.