Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Creating variable names on the fly .NET

  • 22-09-2009 08:30AM
    #1
    Registered Users, Registered Users 2 Posts: 8,648 ✭✭✭


    I am serializing multiple objects into the one xml file but I don't know exactly how many objects I need as I will be looping through and arraylist thus needing to creating variable names on the fly.

    I have based the majority of the working on serializing on the following link

    http://blogs.askquery.com/2007/06/19/how-to-serialize-multiple-objects-in-a-single-xml-file.aspx

    Can anyone help with creating the variable names on the fly like

    var1
    var2 etc

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 2,494 ✭✭✭kayos


    You dont need to. If I read your question right you want to get an array of your object type (you only have one type) from the ArrayList so you can serialize it out to XML. In that case all you need is the below

    SerializeME[] objArray = (objArrayList.ToArray(typeof(SerializeME)) as SerializeME[]);
    

    Where objArrayList is the ArrayList you are working with and the SerializeME is your object type.


  • Registered Users, Registered Users 2 Posts: 8,648 ✭✭✭Trampas


    Thanks.

    Will give that a try and revert back

    Worked a treat. Thanks


Advertisement