My code is as follows:
public static void Output(IEnumerable dataSource) where T : class
{
dataSourceName = (typeof(T).Name);
sw
Johnnie, Please go through msdn guide on switch. Also, the C# language specification clearly defines the compile time error case:
• If the type of the switch expression is sbyte, byte, short, ushort, int, uint, long, ulong, bool, char, string, or an enum-type, or if it is the nullable type corresponding to one of these types, then that is the governing type of the switch statement.
• Otherwise, exactly one user-defined implicit conversion (§6.4) must exist from the type of the switch expression to one of the following possible governing types: sbyte, byte, short, ushort, int, uint, long, ulong, char, string, or, a nullable type corresponding to one of those types.
• Otherwise, if no such implicit conversion exists, or if more than one such implicit conversion exists, a compile-time error occurs.
Hope this helps.