Reputation: 19870
The following code result in different results:
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
Why Type.GetType(n)
finds the type but t.Assembly.GetType(n)
not?
Upvotes: 2
Views: 290
Reputation: 8849
According to http://msdn.microsoft.com/en-us/library/y0cd10tb%28v=vs.110%29.aspx, Assembly.GetType(string)
needs the FULL name of the type.
Try using FullName
instead of ToString()
on the type to get the full name, instead of the short name.
Upvotes: 4