Skip to content

TokenReader<TKind>.TryConsume Method ​

Overloads ​

NameDescription
TryConsume(TKind, Token<TKind>)If the token at the current position is of the specified kind then it is returned and the reader advanced, otherwise the stream does not move.
TryConsume(TKind)If the token at the current position is of the specified kind then the reader advances, otherwise the reader does not move.

TryConsume(TKind, Token<TKind>) ​

If the token at the current position is of the specified kind then it is returned and the reader advanced, otherwise the stream does not move.

c#
public bool TryConsume(TKind kind, out Token<TKind> token);

View source

Parameters ​

NameTypeDescription
kindTKindThe kind of token to consume.
tokenToken<TKind>The consumed token if it was of the specified kind, the default token value otherwise.

Returns ​

Boolean

true if a token was consumed, false otherwise.

TryConsume(TKind) ​

If the token at the current position is of the specified kind then the reader advances, otherwise the reader does not move.

c#
public bool TryConsume(TKind kind);

View source

Parameters ​

NameTypeDescription
kindTKindThe kind of token to consume.

Returns ​

Boolean

true if a token was consumed, false otherwise.