Anonymous object
If you define an object like:
var test = new { firstParam = "testing", secondParam = "testing" };
Is there a way of iterating over the parameters? Something like
foreach(Param p in test)
{
//do something
}
Thanks for any help.
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Kumar AG48 reputationPosted Apr 29, 2009, 12:39 PM EDT
object
[] test = {"testing","testing2","testing3"}; foreach (object obj in test) Console.WriteLine(obj.ToString());Jake Hallon5 reputationPosted Apr 29, 2009, 1:31 PM EDT
Jake Hallon5 reputationPosted Apr 29, 2009, 1:58 PM EDT
var test = new { action = "testing", test = "another" };
System.Reflection.PropertyInfo[] infoArray = test.GetType().GetProperties();
string tmp = "";
foreach (System.Reflection.PropertyInfo info in infoArray)
{ tmp += info.Name + " | " + info.GetValue(test, null); }