C# Reflection and Getting Properties
Posted
by Nathan
on Stack Overflow
See other posts from Stack Overflow
or by Nathan
Published on 2010-05-04T02:56:01Z
Indexed on
2010/05/04
2:58 UTC
Read the original article
Hit count: 258
I have the following dummy class structure and I am trying to find out how to get the properties from each instance of the class People in PeopleList. I know how to get the properties from a single instance of People but can't for the life of me figure out how to get it from PeopleList. I am sure this is really straightforward but can someone point me in the right direction?
public class Example
{
public class People
{
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
private int _age;
public int Age
{
get { return _age; }
set { _age = value; }
}
public People()
{
}
public People(string name, int age)
{
this._name = name;
this._age = age;
}
}
public class PeopleList : List<People>
{
public static void DoStuff()
{
PeopleList newList = new PeopleList();
// Do some stuff
newList.Add(new People("Tim", 35));
}
}
}
© Stack Overflow or respective owner