I'd like to add a generic type method DoSomething<T>
, but for backwards compatibility, I want it to simply pass the type parameter for the generic type from an existing method with the same name.
public void DoSomething<T>(Data data)
{
//do something with Data, it depends on the type of T
}
public void DoSomething(Data data, Type dataType)
{
DoSomething<dataType>(group);
}
However, <dataType>
in the new DoSomething
throws following type checking error: "Type name or namespace expected."
Can someone help me understand the gap in my thinking that makes the above sample a type checking error? Is what I'm doing just... bad design?