using System;
using System.Reflection;
namespace App
{
public class A<T>
{
public WonderfulClass<T> field;
}
public class WonderfulClass<T> { }
class Programm
{
static void Main(string[] args)
{
Type t = typeof(A<>);
Type t1 = t.GetField("field").FieldType;
Type t2 = typeof(WonderfulClass<>);
//Why t1 and t2 are different?
Console.WriteLine(t1 == t2 ? "Equal" : "Not Equal");
}
}
}
using System; using System.Reflection; namespace App { public class A<T> { public WonderfulClass<T> field;
Share
If you inspect the properties, you will notice:
Hence while
t2is an actual definition,t1has already have it’s generic type parameter applied.Note the following: