Class StringExtensions
Defines a collection of extensions for string values.
Inheritance
Namespace: MADE.Data.Validation.Extensions
Assembly: MADE.Data.Validation.dll
Syntax
public static class StringExtensions : object
Methods
| Improve this Doc View SourceContains(String, String, CompareOptions)
Checks whether a phrase contains a specified value using a comparison option.
Declaration
public static bool Contains(this string phrase, string value, CompareOptions compareOption)
Parameters
Type | Name | Description |
---|---|---|
System.String | phrase | The phrase to check. |
System.String | value | The value to find. |
CompareOptions | compareOption | The compare option. |
Returns
Type | Description |
---|---|
System.Boolean | True if the phrase contains the value; otherwise, false. |
IsBoolean(String)
Checks whether a string value is a boolean.
Declaration
public static bool IsBoolean(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if safely parses to a boolean; otherwise, false. |
IsDouble(String)
Checks whether a string value is a double.
Declaration
public static bool IsDouble(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if safely parses to a double; otherwise, false. |
IsFloat(String)
Checks whether a string value is a float.
Declaration
public static bool IsFloat(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if safely parses to a float; otherwise, false. |
IsInt(String)
Checks whether a string value is an integer.
Declaration
public static bool IsInt(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if safely parses to an integer; otherwise, false. |
IsLike(String, String)
Compares a string value against a wildcard pattern, similar to the Visual Basic like operator.
Declaration
public static bool IsLike(this string value, string likePattern)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to compare is like. |
System.String | likePattern | The wildcard like pattern to match on. |
Returns
Type | Description |
---|---|
System.Boolean | True if the value is like the pattern; otherwise, false. |
Remarks
An example of this in use comparing strings with * wildcard pattern.
// result is true
bool result = "MyValue".IsLike("My*");
// result is false
result = "MyValue".IsLike("Hello");
IsNullOrWhiteSpace(String)
Indicates whether a specified string 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 | True if the |