Table of Contents

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 string

The source to be searched.

value string

The string to seek.

comparisonType StringComparison

A 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

text string

Text with the line.

line int

One based number of the line.

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 string

Text 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.