mardi 27 mars 2018

Is it Possible to the Collection using refelection if i have the member of collection?

I have a sample Entity Student as below.

 public class Student
    {
        private string _name;
        public string Name
        {
            get
            {
                return _name;
            }
            set
            {
                _name = value;
            }
        }

        private int _credits;
        public int Credits
        {
            get
            {
                return _credits;
            }
            set
            {
                _credits = value;
            }
        }

    }

I have another Class which is descendent of System.Collections.ObjectModel.Collection as below.

   public class StudentCollection : System.Collections.ObjectModel.Collection<Student>
    {
        //SomeCollection level validations.
    }

Now I am creating the student Collection Like StudentCollection c1 = new StudentCollection();. The question is If I have a student object which is the member of c1 collection then is it possible to get the complete collection to which the object belongs to Using Reflection? If its not possible using reflection then is there some other way out through which the above is possible.





Aucun commentaire:

Enregistrer un commentaire