我有课MyClass<T> where T : IComparable
,我想实现一个将被调用的方法 if T
is String
。我怎样才能做到这一点?
现在我有以下代码:
public void Method()
{
...
Type typeParameterType = typeof(T);
if (typeParameterType.Equals(typeof(String)))
{
// here I can't do (String) anyTTypeValue
// to call handleString(String) method
}
...
}