以下代码会产生不同的结果:
class X<R>
{
public class Y { }
}..。
var t = typeof(X<int>.Y);
var n = t.ToString().Dump(); // <- X`1+Y[System.Int32]
Type.GetType(n).Dump(); // <-- X`1+Y[System.Int32]
t.Assembly.GetType(n).Dump(); // <-- null为什么Type.GetType(n)会找到类型,而t.Assembly.GetType(n)却找不到呢?
发布于 2014-01-06 15:33:28
根据http://msdn.microsoft.com/en-us/library/y0cd10tb%28v=vs.110%29.aspx,Assembly.GetType(string)需要类型的全名。
尝试在类型上使用FullName而不是ToString()来获得全名,而不是短名。
https://stackoverflow.com/questions/20953267
复制相似问题