StringExtensions Class

Version 1.1.28
.NET Framework 4.8
Namespace Skybrud.Essentials.Strings.Extensions
Assembly Skybrud.Essentials.dll
Visibility Public
Keywords Static
Inheritance Object

Static class with various extension methods for String .

public static class StringExtensions { }

Methods

CsvToInt(string) (static)

Converts a comma separated string into an array of integers.

Uppercases the first character of a the specified str. If str is either null or empty, an empty string will be returned instead.

HasValue(string) (static)

Gets whether the input string has a value. This extension method is equal to calling System.String.IsNullOrWhiteSpace(System.String).

Gets whether the input string has a value.

This method may be use to improve the readability of your code - eg. instead of declaring a variable first, and then calling Skybrud.Essentials.Strings.Extensions.StringExtensions.HasValue(System.String) afterwards.

Highlights specified keywords in the input string with the specified className by using a <span> element.

Highlights specified keywords in the input string with the specified className by using a <span> element.

HTML decodes the specified str.

HTML encodes the specified str.

Returns whether the specified input string is alphabetic - meaning it only consists of letters.

Gets whether the specified input string is alphanumeric - meaning it only consists of numbers and letters.

Tries to convert the specified string representation of a logical value to its bool equivalent.

IsDouble(string) (static)

Gets whether the string matches a double (Double ).

Gets whether the string matches a double (Double ).

IsFloat(string) (static)

Gets whether the string matches a float (Single ).

Gets whether the string matches a float (Single ).

IsGuid(string) (static)

Gets whether the string matches a GUID (Guid ).

Gets whether the specified value matches a GUID (Guid ).

IsInt32(string) (static)

Gets whether the string matches an integer (int ).

Returns whether the specified value matches an integer.

IsInt64(string) (static)

Gets whether the string matches a long (long ).

Returns whether the specified value matches a long value.

Alias of Skybrud.Essentials.Strings.Extensions.StringExtensions.IsInt32(System.String). Gets whether the string matches an integer (int ).

Gets whether the input string has a value. This extension method is equal to calling System.String.IsNullOrWhiteSpace(System.String).

Returns whether the specified input string matches a double (Double ).

Converts str into an instance of bool . The input string is considered true if it matches either true, 1, t or on, or false if it matches either false, 0, f or off. All comparisons are case insensitive.

Parses a comma separated string into an array of int .

Parses a comma separated string into an array of long .

HTML encodes the text and replaces text line breaks with HTML line breaks.

Strips all HTML elements from the specified html string.

Strips all HTML elements from the specified html string, but keeps the HTML tags as specified in ignore.

Converts str into an instance of bool . The input string is considered true if it matches either true, 1, t or on (case insensitive).

Converts the specified str to camel case (also referred to as lower camel casing).

Converts the name of the specified enum value to a camel cased string.

Converts the specified enum value to a string with the enum name is formatted using the specified casing.

Converts the specified str to a new string formatted using the specified casing.

ToDouble(string) (static)

Converts input to an instance of Double . If the conversion fails, 0 will be returned instead.

Converts input to an instance of Double . If the conversion fails, fallback will be returned instead.

Parses a string of numeric values into an array of Double . Values in the list that can't be converted to Double will be ignored.

Parses a string of numeric values into an array of Double . Values in the list that can't be converted to Double will be ignored.

ToFloat(string) (static)

Converts input to an instance of Single . If the conversion fails, 0 will be returned instead.

Converts input to an instance of Single . If the conversion fails, fallback will be returned instead.

Parses a string of numeric values into an array of Single . Values in the list that can't be converted to Single will be ignored.

Parses a string of numeric values into an array of Single . Values in the list that can't be converted to Single will be ignored.

ToGuid(string) (static)

Parses input to an instance of Guid . If the conversion fails, System.Guid.Empty will be returned instead.

Parses input to an instance of Guid . If the conversion fails, fallback will be returned instead.

Parses a string of multiple GUIDs into an array of Guid . Supported separators are comma (,), space (), carriage return (\r), new line (\n) and tab (\t).

Values in str that can't be converted to Guid will be ignored.

Parses string of multiple GUIDs into an array of Guid , using the specified array of separators.

Values in str that can't be converted to Guid will be ignored.

Naming of this method is wrong. Use the Skybrud.Essentials.Strings.Extensions.StringExtensions.ToGuid(System.String,System.Guid) method instead.

ToInt32(string) (static)

Converts input to an instance of int . If the conversion fails, 0 will be returned instead.

Converts input to an instance of int . If the conversion fails, fallback will be returned instead.

Parses a string of numeric values into an array of int . Values in the list that can't be converted to int will be ignored.

Parses a string of numeric values into an array of int . Values in the list that can't be converted to int will be ignored.

ToInt64(string) (static)

Converts input to an instance of long . If the conversion fails, 0 will be returned instead.

Converts input to an instance of long . If the conversion fails, fallback will be returned instead.

Parses a string of numeric values into an array of long . Values in the list that can't be converted to long will be ignored.

Parses a string of numeric values into an array of long . Values in the list that can't be converted to long will be ignored.

Converts the specified str to a kebab cased string (lower case words separated by hyphens).

Converts the name of the specified enum value to a kebab cased string (lower case words separated by hyphens).

ToLower(Enum) (static)

Converts the specified enum value to a lower case string.

Converts the specified str to Pascal case (also referred to as upper camel casing).

Converts the name of the specified enum value to a Pascal cased string.

Converts the specified str to a train cased string (upper case words separated by hyphens).

Converts the name of the specified enum value to a train cased string (upper case words separated by hyphens).

Converts the specified str to a lower case string with words separated by underscores.

Converts the specified enum value to a lower case string with words separated by underscores.

ToUpper(Enum) (static)

Converts the specified enum value to an upper case string.

Decodes a URL string.

Encodes a URL string.

Counts number of words in the specified str.