AngleSharp by Florian Rappl

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

 StringExtensions

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 IEnumerable<char> list, char element)

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

public static bool Contains(this string str, string content)

Returns a value indicating whether the specified object occurs within this string. This method might seem obsolete, but it is quite useful in case of porting AngleSharp to a PCL, where String instances to not have a Contains method.

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 CssString(this string value)

Serializes the string to a CSS string.

public static string CssUrl(this string value)

Serializes the string to a CSS url.

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 string GetCompatiblity(this QuirksMode mode)

Retrieves a string describing the compatibility mode of the given quirksmode.

public static bool HasHyphen(this string str, string value)

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 bool IsDigit(this string s)

Determines if the given string consists only of digits (0-9) as specified here: http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#ascii-digits

public static bool IsHex(this string s)

Determines if the given string only contains characters, which are hexadecimal (0-9a-fA-F) as specified here: http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#ascii-hex-digits

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 bool IsOneOf(this string element, string item1, string item2, string item3, string item4, string item5, string item6)

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, string item6, string item7)

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

public static Tuple<Url, Predicate<RenderDevice>> ParseImageCandidate(this string value)

Parses a string that represents an image candidate.

public static IEnumerable<Tuple<Url, Predicate<RenderDevice>>> ParseImageCandidates(this string value)

Parses a list of image candidates, separated by commas.

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 string with the given char delimiter.

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

Splits the char array with the given char delimiter.

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

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

public static string StripLeadingTailingSpaces(this string str)

Strips all leading and tailing space characters from the given string.

public static string StripLeadingTailingSpaces(this char[] array)

Strips all leading and tailing 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 T ToEnum<T>(this string value, T defaultValue) where T : struct, IComparable

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

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 string UrlEncode(this string value, Encoding encoding)

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.