4 April, 2008

Web Services, ArrayLists and Structs, oh my!

4th post of the day... this is what happens when you're anxiously waiting for news

So, when writing code for the Imagine Cup entry, I hit a brick wall trying to serialise an ArrayList of Structs over a Web Service. Here is the way that I found works best:

using System.Xml.Serialization;

public struct Device
    public int id;
    public string fname, room, type;
    public bool is_controllable, status;

public ArrayList GetDevices()
    ArrayList devices = new ArrayList();

    //Logic here

    return devices;