Class StringExtensions
This is an extension implementation of the System.String class using various methods already found in the Microsoft .NET Framework.
Inheritance
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class StringExtensions
Methods
| Improve this DocFormatWith(String, IFormatProvider, Object[])
Replaces the format
item in a specified string with the string representation of a corresponding object in a specified array.
Declaration
public static string FormatWith(this string format, IFormatProvider provider, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | A composite format string. |
System.IFormatProvider | provider | An object that supplies culture-specific formatting information. |
System.Object[] | args | An object array that contains zero or more objects to format. |
Returns
Type | Description |
---|---|
System.String | A copy of |
FormatWith(String, Object[])
Replaces the format
item in a specified string with the string representation of a corresponding object in a specified array.
Declaration
public static string FormatWith(this string format, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | A composite format string. |
System.Object[] | args | An object array that contains zero or more objects to format. |
Returns
Type | Description |
---|---|
System.String | A copy of |
FromBase64(String)
Converts the specified string, which encodes binary data as base-64 digits, to an equivalent 8-bit unsigned integer array.
Declaration
public static byte[] FromBase64(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string to convert. |
Returns
Type | Description |
---|---|
System.Byte[] | An array of 8-bit unsigned integers that is equivalent to |
IsNullOrEmpty(String)
Determines whether the specified value
is null or an System.String.Empty string.
Declaration
public static bool IsNullOrEmpty(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string to test. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsNullOrWhiteSpace(String)
Determines whether the specified value
is null, empty, or consists only of white-space characters.
Declaration
public static bool IsNullOrWhiteSpace(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string to test. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Join(String[], String)
Concatenates all the elements of a string array, using the specified separator between each element.
Declaration
public static string Join(this string[] value, string separator)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | value | An array that contains the elements to concatenate. |
System.String | separator | The string to use as a separator. The separator is included in the returned string only if value has more than one element. |
Returns
Type | Description |
---|---|
System.String | A string that consists of the elements in |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
Join(String[], String, Int32, Int32)
Concatenates all the elements of a string array, using the specified separator between each element.
Declaration
public static string Join(this string[] value, string separator, int startIndex, int count)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | value | An array that contains the elements to concatenate. |
System.String | separator | The string to use as a separator. The separator is included in the returned string only if value has more than one element. |
System.Int32 | startIndex | The first element in |
System.Int32 | count | The number of elements of |
Returns
Type | Description |
---|---|
System.String | A string that consists of the elements in |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
SubstringBefore(String, String, StringComparison)
Retrieves a substring from the specified value
. The substring starts at position 0 and continues until the first occurrence of match
.
Declaration
public static string SubstringBefore(this string value, string match, StringComparison comparisonType = StringComparison.OrdinalIgnoreCase)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The System.String to extend. |
System.String | match | The match that will define the stopping point. |
System.StringComparison | comparisonType | One of the enumeration values that specifies the rules for the search. |
Returns
Type | Description |
---|---|
System.String | A substring that contains only the value just before |
ToCasing(String, CasingMethod)
Converts the specified value
to either lowercase, UPPERCASE, Title Case or unaltered.
Declaration
public static string ToCasing(this string value, CasingMethod method)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to convert to one of the values in CasingMethod. |
CasingMethod | method | The method to use in the conversion. |
Returns
Type | Description |
---|---|
System.String | A System.String that corresponds to |
Remarks
Uses System.Globalization.CultureInfo.InvariantCulture for the conversion.
ToCasing(String, CasingMethod, CultureInfo)
Converts the specified value
to either lowercase, UPPERCASE, Title Case or unaltered using the specified culture
.
Declaration
public static string ToCasing(this string value, CasingMethod method, CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to convert to one of the values in CasingMethod. |
CasingMethod | method | The method to use in the conversion. |
System.Globalization.CultureInfo | culture | The culture rules to apply the conversion. |
Returns
Type | Description |
---|---|
System.String | A System.String that corresponds to |
ToUri(String)
Converts the specified absolute uriString
to its equivalent System.Uri representation.
Declaration
public static Uri ToUri(this string uriString)
Parameters
Type | Name | Description |
---|---|---|
System.String | uriString | A string that identifies the resource to be represented by the System.Uri instance. |
Returns
Type | Description |
---|---|
System.Uri | A System.Uri that corresponds to |
Remarks
This method uses the System.UriKind.Absolute when converting the uriString
.
ToUri(String, UriKind)
Converts the specified uriString
to its equivalent System.Uri representation.
Declaration
public static Uri ToUri(this string uriString, UriKind uriKind)
Parameters
Type | Name | Description |
---|---|---|
System.String | uriString | A string that identifies the resource to be represented by the System.Uri instance. |
System.UriKind | uriKind | Specifies whether the URI string is a relative URI, absolute URI, or is indeterminate. |
Returns
Type | Description |
---|---|
System.Uri | A System.Uri that corresponds to |