संपादित करें

इसके माध्यम से साझा किया गया


SequenceMarshal.TryRead<T>(SequenceReader<Byte>, T) Method

Definition

Attempts to read the specified type out of the buffer. It's dangerous to use this method with arbitrary structs - see remarks for more information.

public:
generic <typename T>
 where T : value class static bool TryRead(System::Buffers::SequenceReader<System::Byte> % reader, [Runtime::InteropServices::Out] T % value);
public static bool TryRead<T> (ref System.Buffers.SequenceReader<byte> reader, out T value) where T : struct;
static member TryRead : SequenceReader * 'T -> bool (requires 'T : struct)
Public Shared Function TryRead(Of T As Structure) (ByRef reader As SequenceReader(Of Byte), ByRef value As T) As Boolean

Type Parameters

T

The type of the value.

Parameters

reader
SequenceReader<Byte>

A reference to the sequence reader.

value
T

The returned value if the read was successful. value will be default if failed (due to lack of space).

Returns

true if the read attempt was successful, false otherwise.

Remarks

Important

The read is a straight copy of bits. If a struct depends on the specific state of its members to behave correctly, this can lead to exceptions. If you're reading endian specific integers, use the explicit overloads such as TryReadLittleEndian(SequenceReader<Byte>, Int32).

Applies to