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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Creating variable names on the fly .NET

  • 22-09-2009 7:30am
    #1
    Registered Users, Registered Users 2 Posts: 7,987 ✭✭✭


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


    Thanks.

    Will give that a try and revert back

    Worked a treat. Thanks


Advertisement