samedi 18 janvier 2020

Find a class field's comes from another calsses

public class MyClassA
{
    public int Test;
    public List<MyClassB> StrTest; 
    void MyClassA()
    {
        StrTest = new List<MyClassB>();
        StrTest.Add(new MyClassB());
    }
}
public class MyClassB
{
    public int value;
}
private string ToStr()
{
    // By Reflection 
}
void main()
{
   MyClassA A = new MyClassA();
   string str = ToStr(A.StrTest[0].value);
   Console.WriteLine(str);
}

The output is "A.StrTest[0].value".

The main question is how can find a class field's comes from another classes





Aucun commentaire:

Enregistrer un commentaire