예제 #1
0
    public static List <MyItem> Deserialize(byte[] data)
    {
        var ret = new List <MyItem>();

        using (MemoryStream m = new MemoryStream(data))
        {
            using (BinaryReader reader = new BinaryReader(m, System.Text.Encoding.UTF8))
            {
                while (m.Position < m.Length)
                {
                    var itemLength = reader.ReadInt32();
                    var itemBytes  = reader.ReadBytes(itemLength);
                    var item       = MyItem.Desserialize(itemBytes);
                    ret.Add(item);
                }
            }
        }

        return(ret);
    }