Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Creating variable names on the fly .NET

Options
  • 22-09-2009 8:30am
    #1
    Registered Users Posts: 7,681 ✭✭✭


    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 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 Posts: 7,681 ✭✭✭Trampas


    Thanks.

    Will give that a try and revert back

    Worked a treat. Thanks


Advertisement