Class StringExtension
- Namespace
- Loehnert.Utility.Extensions
- Assembly
- Loehnert.Utility.dll
Extensions for string.
public static class StringExtension
- Inheritance
-
StringExtension
- Inherited Members
Methods
Contains(string, string, StringComparison)
Returns a value indicating whether a string contains a specified substring by using a StringComparison.
public static bool Contains(this string source, string value, StringComparison comparisonType)
Parameters
source
stringThe source to be searched.
value
stringThe string to seek.
comparisonType
StringComparisonA value that determines how this string and value are compared.
Returns
- bool
true if the value parameter occurs within this string, or if value is the empty string (""); otherwise, false.
Exceptions
- ArgumentException
Thrown when
value
is null or empty.
GetLine(string, int)
Gets the line text by line number.
public static string GetLine(this string text, int line)
Parameters
Returns
- string
The text of the line with the number.
Remarks
Supports only CRLF and LF as lines separator.
Exceptions
- ArgumentNullException
Thrown when
text
is null.- ArgumentOutOfRangeException
Thrown when
line
is greater than the number of lines (see GetLineCount(string)) or less than 1.
GetLineCount(string)
Gets the count of the lines.
public static int GetLineCount(this string text)
Parameters
text
stringText for counting.
Returns
- int
The amount of the lines.
Remarks
Supports only CRLF and LF as lines separator.
Exceptions
- ArgumentNullException
Thrown when
text
is null.