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
sourcestringThe source to be searched.
valuestringThe string to seek.
comparisonTypeStringComparisonA 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
valueis 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
textis null.- ArgumentOutOfRangeException
Thrown when
lineis 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
textstringText for counting.
Returns
- int
The amount of the lines.
Remarks
Supports only CRLF and LF as lines separator.
Exceptions
- ArgumentNullException
Thrown when
textis null.