Class StringExtensions
Defines a collection of extensions for string values.
Inheritance
Namespace: MADE.Data.Converters.Extensions
Assembly: MADE.Data.Converters.dll
Syntax
public static class StringExtensions : object
Methods
| Improve this Doc View SourceFromBase64(String, Encoding)
Converts a Base64 string to a value using the specified encoding.
Declaration
public static string FromBase64(this string base64Value, Encoding encoding = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | base64Value | The Base64 value to convert. |
Encoding | encoding | The encoding to get the value string while converting. |
Returns
Type | Description |
---|---|
System.String | The string value representing the Base64 string. |
ToBase64(String, Encoding)
Converts a value to a Base64 string using the specified encoding.
Default encoding is UTF-8.
Declaration
public static string ToBase64(this string value, Encoding encoding = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string value to convert. |
Encoding | encoding | The encoding to get the value bytes while converting. |
Returns
Type | Description |
---|---|
System.String | The Base64 string representing the value. |
ToBoolean(String)
Converts a string value to a boolean.
Declaration
public static bool ToBoolean(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to convert. |
Returns
Type | Description |
---|---|
System.Boolean | The boolean representing the value. |
ToDefaultCase(String)
Converts a value to default case using the case rules of the invariant culture.
Declaration
public static string ToDefaultCase(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | The converted default case string. |
Examples
string converted = "HELLO, WORLD".ToDefaultCase(); // converted = "Hello, world".
| Improve this Doc View SourceToDouble(String)
Converts a string value to a double.
Declaration
public static double ToDouble(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to convert. |
Returns
Type | Description |
---|---|
System.Double | The double representing the value. |
ToFloat(String)
Converts a string value to a float.
Declaration
public static float ToFloat(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to convert. |
Returns
Type | Description |
---|---|
System.Single | The float representing the value. |
ToInt(String)
Converts a string value to an integer.
Declaration
public static int ToInt(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to convert. |
Returns
Type | Description |
---|---|
System.Int32 | The int representing the value. |
ToMemoryStreamAsync(String)
Converts a string value to a
Declaration
public static async Task<MemoryStream> ToMemoryStreamAsync(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to convert. |
Returns
Type | Description |
---|---|
Task<MemoryStream> | A |
ToNullableDouble(String)
Converts a string value to a nullable double.
Declaration
public static double? ToNullableDouble(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to convert. |
Returns
Type | Description |
---|---|
System.Nullable<System.Double> | The nullable double representing the value. |
ToNullableFloat(String)
Converts a string value to a nullable float.
Declaration
public static float? ToNullableFloat(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to convert. |
Returns
Type | Description |
---|---|
System.Nullable<System.Single> | The nullable float representing the value. |
ToNullableInt(String)
Converts a string value to a nullable integer.
Declaration
public static int? ToNullableInt(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to convert. |
Returns
Type | Description |
---|---|
System.Nullable<System.Int32> | The nullable integer representing the value. |
ToTitleCase(String)
Converts a value to title case using the case rules of the invariant culture.
Declaration
public static string ToTitleCase(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | The converted title case string. |
Examples
string converted = "HELLO, WORLD".ToTitleCase(); // converted = "Hello, World".
| Improve this Doc View SourceTruncate(String, Int32)
Truncates a string value to the specified length with an ellipsis.
Declaration
public static string Truncate(this string value, int maxLength)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to truncate. |
System.Int32 | maxLength | The maximum length of the value. |
Returns
Type | Description |
---|---|
System.String | A truncated string with ellipsis if the value's length is greater than the |