AngleSharp by AngleSharp

<PackageReference Include="AngleSharp" Version="1.0.0" />

 StringExtensions

public static class StringExtensions
Useful methods for string objects.
public static string Collapse(this string str)

Collapses all spaces in the given string.

public static string CollapseAndStrip(this string str)

Collapses and strips all spaces in the given string.

public static bool Contains(this string[] list, string element, StringComparison comparison = 4)

Examines if a the given list of string contains a certain element.

public static string CssFunction(this string value, string argument)

Creates a CSS function from the string with the given argument.

public static string CssString(this string value)

Serializes the string to a CSS string.

public static int FromDec(this string s)

Converts the given string to an integer.

public static int FromHex(this string s)

Converts the given string to an integer.

public static bool Has(this string value, char chr, int index = 0)

Checks if the given string has a certain character at a specific index. The index is optional (default is 0).

public static bool HasHyphen(this string str, string value, StringComparison comparison = 4)

Checks if the provided string starts with the given value, either by exactly matching it, or by comparing against the start including an additional dash character.

public static string HtmlEncode(this string value, Encoding encoding)

Replaces characters in names and values that cannot be expressed by using the given encoding with &#...; base-10 unicode point.

public static string HtmlLower(this string value)

Transforms the given string to lower case by the HTML specification.

public static bool Is(this string current, string other)

Checks if two strings are exactly equal.

public static bool IsCustomElement(this string tag)

Checks if the given string satisfies the rules for a custom element name.

public static bool Isi(this string current, string other)

Checks if two strings are equal when viewed case-insensitive.

public static bool IsOneOf(this string element, string item1, string item2)

Examines if the given element is equal to one of the given elements.

public static bool IsOneOf(this string element, string item1, string item2, string item3)

Examines if the given element is equal to one of the given elements.

public static bool IsOneOf(this string element, string item1, string item2, string item3, string item4)

Examines if the given element is equal to one of the given elements.

public static bool IsOneOf(this string element, string item1, string item2, string item3, string item4, string item5)

Examines if the given element is equal to one of the given elements.

public static string NormalizeLineEndings(this string value)

Replaces every occurrence of a "CR" (U+000D) character not followed by a "LF" (U+000A) character, and every occurrence of a "LF" (U+000A) character not preceded by a "CR" (U+000D) character, by a two-character string consisting of a U+000D CARRIAGE RETURN "CRLF" (U+000A) character pair.

public static Sandboxes ParseSecuritySettings(this string value, bool allowFullscreen = false)

Converts the given value to a sandbox flag.

public static string ReplaceFirst(this string text, string search, string replace)

Replaces the first occurance of the string search with replace.

public static string[] SplitCommas(this string str)

Splits the string on commas.

public static string[] SplitSpaces(this string str)

Splits the string on space characters.

public static string[] SplitWithoutTrimming(this string str, char c)

Splits the char array with the given char delimiter.

public static string[] SplitWithTrimming(this string str, char ch)

Splits the string with the given char delimiter and trims the leading and tailing spaces.

public static string StripLeadingTrailingSpaces(this string str)

Strips all leading and trailing space characters from the given char array.

public static string StripLineBreaks(this string str)

Strips all line breaks from the given string.

public static bool ToBoolean(this string value, bool defaultValue = false)

Converts the given value to a boolean (or not).

public static double ToDouble(this string value, double defaultValue = 0)

Converts the given value to a double (or not).

public static string ToEncodingType(this string encType)

Converts the current string to one of the encoding types.

public static T ToEnum<T>(this string value, T defaultValue) where T : struct, Enum

Converts the given value to an enumeration value (or not).

public static string ToFormMethod(this string method)

Converts the current string to one of the form methods.

public static int ToInteger(this string value, int defaultValue = 0)

Converts the given value to an integer (or not).

public static uint ToInteger(this string value, uint defaultValue = 0)

Converts the given value to an unsigned integer (or not).

public static byte[] UrlDecode(this string value)

Decodes the provided percent encoded string. An exception is thrown in case of an invalid input value.

public static string UrlEncode(this byte[] content)

Replaces characters in names and values that should not be in URL values. Replaces the bytes 0x20 (U+0020 SPACE if interpreted as ASCII) with a single 0x2B byte ("+" (U+002B) character if interpreted as ASCII). If a byte is not in the range 0x2A, 0x2D, 0x2E, 0x30 to 0x39, 0x41 to 0x5A, 0x5F, 0x61 to 0x7A, it is replaced with its hexadecimal value (zero-padded if necessary), starting with the percent sign.