Skip to content

JsonElement.TryGetLine Method

Definition

Namespace: Corvus.Text.Json
Assembly: Corvus.Text.Json.dll

Overloads

Method Description
TryGetLine(int, ReadOnlyMemory<byte>) Tries to get the specified line from the original source document as UTF-8 bytes.
TryGetLine(int, string?) Tries to get the specified line from the original source document as a string.

TryGetLine(int, ReadOnlyMemory<byte>)

Source: JsonElement.SourceLocation.cs

Tries to get the specified line from the original source document as UTF-8 bytes.

public bool TryGetLine(int lineNumber, out ReadOnlyMemory<byte> line)

Parameters

Name Type Description
lineNumber int The 1-based line number to retrieve.
line ReadOnlyMemory<byte> When this method returns, contains the UTF-8 bytes of the line if successful.

Returns

bool

true if the line was successfully retrieved; otherwise, false.

Remarks

This method returns false when the backing document does not retain the original source bytes, or when lineNumber is out of range.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

TryGetLine(int, string?)

Source: JsonElement.SourceLocation.cs

Tries to get the specified line from the original source document as a string.

public bool TryGetLine(int lineNumber, out string? line)

Parameters

Name Type Description
lineNumber int The 1-based line number to retrieve.
line string? When this method returns, contains the line text if successful.

Returns

bool

true if the line was successfully retrieved; otherwise, false.

Remarks

This method returns false when the backing document does not retain the original source bytes, or when lineNumber is out of range.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create and review issues and pull requests.

Open an issue