BinarySerializerSerializeValueArrayT Method

Serializes an Array of ValueType elements into a byte array.

Definition

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

Parameters

array  T
The array to serialize.

Type Parameters

T
Element type of the array. Must be a ValueType that has no references.

Return Value

Byte
The byte array representation of the array.

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 TrySerializeValueArrayT(T, Byte) method that performs the check.

See Also