Method TryWrite
TryWrite<T>(ExSpan<byte>, in T)
Tries to write a structure of type T
into a span of bytes (尝试将类型为 T
的结构体写入到字节的跨度中).
public static bool TryWrite<T>(ExSpan<byte> destination, in T value) where T : struct
Parameters
destination
ExSpan<byte>The destination span (目标跨度).
value
TThe structure to be written to the span (要写入到范围的结构体).
Returns
- bool
true if the write operation succeeded; otherwise, false. The method returns false if the span is too small to contain
T
(如果写入操作成功,则为 true;否则为 false。 如果跨度太小无法包含T
,则此方法返回 false).
Type Parameters
T
The element type (元素的类型).
Exceptions
- ArgumentException
T contains managed object references.