Not sure I understand what you're trying to accomplish...If you want
the values of the properties of a particular object, then you can use
reflection - typeof(MyType).GetProperties() (or something like that)
gives you a collection of PropertyInfo objects, each of which you can
use to retrieve a value - but if you just take that value and store it
in an ArrayList, you lose the important stuff, like the name of the
property...

I think more details of your requirements would be helpful.

On Dec 16, 4:59 am, raddars <[email protected]> wrote:
> Hi all,
> Is it possible to loop through an object and put each element into an
> array?
>
> I have the following code breaks on the foreach because of
> GetEnumerator not being a public definition.  Not sure how to correct
> it or what that means!
> Many thanks,
>
>   try
>         {
>             XmlSerializer deserializer = new XmlSerializer(typeof
> (Main));
>             textReader = new StreamReader
> (System.AppDomain.CurrentDomain.BaseDirectory + "test.xml", true);
>             mainObj = (Main)deserializer.Deserialize
> (textReader);
>             foreach(object o in mainObj) {
>                 myArraylist.Add(o);
>             }
>         }

Reply via email to