다음을 통해 공유


StringExtensions.FindNewline Method

Definition

Finds the index in the given buffer of a newline character, either the first or the last (based on the parameters). If a combined newline (\r\n), the index returned is that of the last character in the sequence.

public static int FindNewline (byte[] buffer, int startOffset, int length, bool reverse, System.Text.Encoding encoding, string delimiter = default);
static member FindNewline : byte[] * int * int * bool * System.Text.Encoding * string -> int
Public Shared Function FindNewline (buffer As Byte(), startOffset As Integer, length As Integer, reverse As Boolean, encoding As Encoding, Optional delimiter As String = Nothing) As Integer

Parameters

buffer
Byte[]

The buffer to search in.

startOffset
Int32

The index of the first byte to start searching at.

length
Int32

The number of bytes to search, starting from the given startOffset.

reverse
Boolean

If true, searches from the startOffset down to the beginning of the buffer. If false, searches upwards.

encoding
Encoding
delimiter
String

Returns

The index of the closest newline character in the sequence (based on direction) that was found. Returns -1 if not found.

Applies to