Method Serialize
Serialize()
Serializes the current instance into a binary format and returns the resulting data as a byte array.
public byte[] Serialize()
Returns
- byte[]
A byte array containing the binary representation of this instance.
Serialize(string)
Serializes the current instance into a binary format and writes the data to the specified file.
public void Serialize(string path)
Parameters
path
stringThe file path where the serialized data will be written. Must not be null or empty.
Exceptions
- ArgumentNullException
Thrown if
path
is null or empty.- IOException
Thrown if an I/O error occurs while writing to the file.
Serialize(Stream)
Serializes the current instance into a binary format and writes it to the provided stream.
public void Serialize(Stream stream)
Parameters
stream
StreamThe writable stream to which the serialized data will be written. Must not be null and must support writing.
Exceptions
- ArgumentNullException
Thrown if
stream
is null.- ArgumentException
Thrown if
stream
is not writable.