Annoymous type get properties and values
1 static void AnnoymousReflection() 2 { 3 var obj = new 4 { 5 First = 3456.345, 6 Second = 43545657, 7 Third = 'A', 8 Forth = "Test", 9 Fifth = true, 10 Sixth = 10.043M 11 }; 12 13 Type type = obj.GetType(); 14 PropertyInfo[] pis = type.GetProperties(); 15 if(pis!=null && pis.Any()) 16 { 17 foreach(var pi in pis) 18 { 19 var piValue = pi.GetValue(obj); 20 Console.WriteLine($"Name={pi.Name},Value={piValue}"); 21 } 22 } 23 24 }