BinarySerializerSerializeValueTypeT(T) Method
Serializes the specified value into a byte array.
Namespace: KGySoft.Serialization.BinaryAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.1.0
[SecurityCriticalAttribute]
public static byte[] SerializeValueType<T>(
in T value
)
where T : struct, new(), Object
<SecurityCriticalAttribute>
Public Shared Function SerializeValueType(Of T As {Structure, New, Object}) (
ByRef value As T
) As Byte()
public:
[SecurityCriticalAttribute]
generic<typename T>
where T : value class, gcnew(), Object
static array<unsigned char>^ SerializeValueType(
[InAttribute] T% value
)
[<SecurityCriticalAttribute>]
static member SerializeValueType :
value : 'T byref -> byte[] when 'T : struct, new() and Object
- value T
- The value to serialize.
- T
- The type of the object to serialize. It must be a value type that does not contain references.
ByteThe byte array representation of the specified
value.
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.