为什么下面编译?仿制药和铸造
public IList<T> Deserialize<T>(string xml)
{
if (typeof(T) == typeof(bool))
return (IList<T>)DeserializeBools(xml);
return null;
}
private static IList<bool> DeserializeBool(string xml) { ... do stuff ... }
但这并不
public MyClass<T> GetFromDb<T>(string id)
{
if (typeof(T) == typeof(bool))
return (MyClass<T>)GetBoolValue(id); <-- compiler error here
return null;
}
private static MyClass<bool> GetBoolValue(string id) { ... do stuff ... }
什么是编译错误... – 2010-10-29 10:47:40
错误说的是什么? – 2010-10-29 10:49:23
无法投射'MyClass'类型的表达式来键入'MyClass ' –
Magpie
2010-10-29 10:49:55