I have classes like this:
class A
{
public int x;
public int y;
}
class B
{
public int x;
public int y;
}
class C
{
public A a;
public B b;
}
public class Test<T> where T : class, new()
{
public Test()
{
FieldInfo[] x = typeof(T).GetFields().ToArray();
Type y = x[0].GetType();
}
}
When I declare Test<C> c = new T
typeof(T).GetFields().ToArray()
Returns the two fields a of type A
and b of type B
as expected. but when I want to get type of first field itself, like this: Type y = x[0].GetType();
, the value of y is System.Reflection.RtFieldInfo
and not A
Why is it so? I need to get to the class A
so that I can get its fields and ...
Aucun commentaire:
Enregistrer un commentaire