jeudi 24 juin 2021

If a class contain a list of another class's object then how to access the list element using reflection in C#?

I have the following 3 classes and I want to print all values of the list stdInfo from the Access class using reflection but I have faced trouble doing this. please, someone, help me to do this task:

public class Student
{
      public int ID { get; set; }
      public List<StudentInfo> stdInfo { get; set; }
      public Student()
      {

        }
        public Student(int Id, List<StudentInfo> info)
        {
            this.ID = Id;
            stdInfo = info;
        }
 }


public class StudentInfo
{
        public int ID { get; set; }
        public string Name { get; set; }
        public StudentInfo()
        {

        }
        public StudentInfo(int id,string name)
        {
            ID = id;
            Name = name;
        }
}


public class Access
{
     
}




Aucun commentaire:

Enregistrer un commentaire