BinarySerializerSerializeValueTypeT(T) Method

Serializes the specified value into a byte array.

Definition

Namespace: KGySoft.Serialization.Binary
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.1.0
C#
[SecurityCriticalAttribute]
public static byte[] SerializeValueType<T>(
	 in T value
)
where T : struct, new(), Object

Parameters

value  T
The value to serialize.

Type Parameters

T
The type of the object to serialize. It must be a value type that does not contain references.

Return Value

Byte
The byte array representation of the specified value.

Remarks

  Security Note

Do not use this method with T types that have references. When using this library with a compiler that recognizes the unmanaged constraint, then this is enforced for direct calls; however, by using reflection T can be any value type. For performance reasons this method does not check if T has references, but you can call the TrySerializeValueTypeT(T, Byte) method that performs the check.

See Also