Question: Suppose I have a class named foo, and it has 3 public members foo1, foo2, and foo3.

Now suppose I'm writing a function that takes an instance of class foo as a parameter, but when I'm writing this function I have no idea what public members it has.

Is there a way for me to determine at run-time that it has public members foo1, foo2, foo3 *AND ONLY* foo1, foo2, foo3. IE - find out what all the public members are?

And can I also determine their types?

Answer: 
Well, that's what Reflection is there for :

```
Type myObjectType = typeof(foo);

System.Reflection.FieldInfo[] fieldInfo = myObjectType.GetFields();
foreach (System.Reflection.FieldInfo info in fieldInfo)
   Console.WriteLine(info.Name); // or whatever you desire to do with it

```
```
foreach(PropertyInfo pi in yourObject.GetType().GetProperties())
{
   Type theType = pi.PropertyType;
}

```