0
    private byte[] ObjectToByteArray(Object obj)
    {
        if (obj == null)
            return null;
        BinaryFormatter bf = new BinaryFormatter();
        MemoryStream ms = new MemoryStream();
        bf.Serialize(ms, obj);
        return ms.ToArray();
    }


    private Object ByteArrayToObject(byte[] arrBytes)
    {
        MemoryStream memStream = new MemoryStream();
        BinaryFormatter binForm = new BinaryFormatter();
        memStream.Write(arrBytes, 0, arrBytes.Length);
        memStream.Seek(0, SeekOrigin.Begin);
        Object obj = (Object)binForm.Deserialize(memStream);
        return obj;
    }

「BinaryFormatter」クラスを定義していませんでした。

4

1 に答える 1

1

Silverlight には BinaryFormatter や SoapFormatter などのクラスはありませんが、Silverlight でサポートされているDataContractJsonSerializerを使用できます。

于 2012-09-13T08:11:01.607 に答える