.NET: How to binary serialize an object with attribute [DataContract]?
.net, wcf
Solution
The solution is to use DataContractSerializer to serialize the object.
Problem
Class marked as [DataContract] can't be ISerializable at the same time. OK, so how can I serialize this type of object to a binary stream? ``` private byte[] GetRoomAsBinary(Room room) { MemoryStream stream = new MemoryStream(); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(stream, room); return stream.ToArray(); } ``` I can't make it work without Room being ISerializable. How can I get a byte array from object some other way?