2
下面的代碼導致不同的結果:Type.GetType()和Assembly.GetType()返回不同的結果
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)
?
'T Dump(T v)'來自LINQPad,它返回值並輸出它。 –