It seems that you want to know about Binary Serialization . From the link:
Serialization can be defined as the process of storing the state of an object in the medium store. During this process, the public and private fields of the object and the class name , including the assembly containing the class, are converted to a byte stream , which is then written to the data stream. When an object is subsequently deserialized, an exact clone of the original object is created.
A more specific example of Binary Serialization for C # (oriented to the .NET Framework 4.5) can be found here . Short review; you must annotate the class you want to serialize and deserialize using the [Serializable] tag, and then use the Formatter instance to actually serialize / deserialize.
So, in Perl, where you can just say:
pack TEMPLATE,LIST
In C # you will need the following:
[Serializable] public class MyObject { public int n1 = 0; public int n2 = 0; public String str = null; }
To solve the idea that you want to manage a serialization pattern, you will most likely have to implement ISerializable yourself. Here is an MSDN article on custom binary serialization . By implementing the interface yourself, you get a very high level of binary template management in exchange for high complexity in providing functionality.
Az za source share