public static void Main()
var testObj = new MyTest() { NameName = "Peter", NumberNumber = 15 };
PropertyInfo[] myPropertyInfo;
string typeName = typeof(MyTest).ToString();
myPropertyInfo = Type.GetType(typeName).GetProperties();
Console.WriteLine("Properties of " + typeName + " are:");
for (int i = 0; i < myPropertyInfo.Length; i++)
string propName = myPropertyInfo[i].Name;
Console.WriteLine(propName + ": " + GetPropValue(testObj, propName));
public static object GetPropValue(object src, string propName)
return src.GetType().GetProperty(propName).GetValue(src, null);
public int NumberNumber {