Exemplo n.º 1
0
    byte[] SerializeDictionary(Dictionary <string, Fence> dict)
    {
        BinaryFormatter bf = new BinaryFormatter();

        FenceData[] fenceData = new FenceData[dict.Count];
        int         i         = 0;

        foreach (Fence item in dict.Values)
        {
            fenceData[i] = Fence.FenceToData(item);
            i++;
        }
        using (MemoryStream ms = new MemoryStream()) {
            bf.Serialize(ms, fenceData);
            return(ms.ToArray());
        }
    }