LineTerminators Class
Provides helper constants and methods for working with line terminators.
public static class LineTerminators
- Inheritance:
- object object
Properties
SystemLineTerminator
The LineTerminator as determined by the system.
Methods
GetLineTerminatorAtOffset(ReadOnlySpan<char>, int)
Returns a nullable LineTerminator indicating the line terminator at the offset of the specified text, if any.
public static LineTerminator? GetLineTerminatorAtOffset(ReadOnlySpan<char> text, int offset)
| Parameter | Type | Description |
|---|---|---|
| text | ReadOnlySpan<char> | The text to examine. |
| offset | int | The offset at which a possible line terminator occurs. |
Returns
GetText(LineTerminator)
Returns the text representation of the specified LineTerminator.
public static string GetText(this LineTerminator lineTerminator)
| Parameter | Type | Description |
|---|---|---|
| lineTerminator | LineTerminator | The LineTerminator to examine. |
Returns
GetTextLength(LineTerminator?)
Returns the text length of the specified LineTerminator.
public static int GetTextLength(this LineTerminator? lineTerminator)
| Parameter | Type | Description |
|---|---|---|
| lineTerminator | LineTerminator? | The LineTerminator to examine. |
Returns
Remarks
A text length of 0 is returned for invalid LineTerminator values.
IndexOfLineTerminator(ReadOnlySpan<char>)
Returns the index of the first line terminator character in the specified text span.
public static int IndexOfLineTerminator(this ReadOnlySpan<char> textSpan)
| Parameter | Type | Description |
|---|---|---|
| textSpan | ReadOnlySpan<char> | The text span to examine. |
Returns
- int:
The index of the first line terminator character, or
-1if none is found.
IsLineTerminator(char)
Returns whether the specified character is a line terminator character.
public static bool IsLineTerminator(this char ch)
| Parameter | Type | Description |
|---|---|---|
| ch | char | The character to examine. |
Returns
- bool:
trueif the specified character is a line terminator character; otherwise,false.
Remarks
The LineTerminator enumeration defines the line terminators that are supported.
IsLineTerminator(string?)
Returns whether the specified string is a line terminator string.
public static bool IsLineTerminator(this string? text)
| Parameter | Type | Description |
|---|---|---|
| text | string | The string to examine. |
Returns
- bool:
trueif the specified string is a line terminator string; otherwise,false.
Remarks
The LineTerminator enumeration defines the line terminators that are supported.
LastIndexOfLineTerminator(ReadOnlySpan<char>)
Returns the index of the last line terminator character in the specified text span.
public static int LastIndexOfLineTerminator(this ReadOnlySpan<char> textSpan)
| Parameter | Type | Description |
|---|---|---|
| textSpan | ReadOnlySpan<char> | The text span to examine. |
Returns
- int:
The index of the last line terminator character, or
-1if none is found.
ToLineTerminator(char)
Examines the specified character and returns the appropriate LineTerminator value if it is a line terminator character.
public static LineTerminator? ToLineTerminator(this char ch)
| Parameter | Type | Description |
|---|---|---|
| ch | char | The character to examine. |
Returns
- LineTerminator?:
A LineTerminator value if the character is a line terminator character, otherwise,
null.
ToLineTerminator(string?)
Examines the specified string and returns the appropriate LineTerminator value if it is a line terminator string.
public static LineTerminator? ToLineTerminator(this string? text)
| Parameter | Type | Description |
|---|---|---|
| text | string | The string to examine. |
Returns
- LineTerminator?:
A LineTerminator value if the string is a line terminator string, otherwise,
null.
Fields
CRChar
The CR character.
public const char CRChar = '\r'
CRLFString
The CRLF text.
public const string CRLFString = "\r\n"
CRString
The CR text.
public const string CRString = "\r"
LFChar
The LF character.
public const char LFChar = '\n'
LFString
The LF text.
public const string LFString = "\n"
LineTerminatorCharArray
The array of standard line terminator characters.
public static readonly char[] LineTerminatorCharArray