Method Serialize
Serialize()
Serializes this 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 this instance into a binary format and writes it to the specified file path. This method converts the current instance into its binary representation and writes the data to a file at the given path.
public void Serialize(string path)
Parameters
path
stringThe file path where the serialized data will be written. This path must not be null or empty.
Exceptions
- ArgumentNullException
Thrown if the provided
path
is null or empty.- IOException
Thrown if an I/O error occurs while trying to write to the specified file.
Serialize(Stream)
Serializes this instance into a binary format and writes it to the specified stream.
public void Serialize(Stream stream)
Parameters
stream
StreamThe stream to which the serialized data will be written. The stream must be writable and must not be null.
Exceptions
- ArgumentNullException
Thrown if the provided stream is null.
- ArgumentException
Thrown if the provided stream is not writable.