Table of Contents

Class StringExtensions

Namespace
MADE.Data.Validation.Extensions
Assembly
MADE.Data.Validation.dll

Defines a collection of extensions for string values.

public static class StringExtensions
Inheritance
StringExtensions
Inherited Members

Methods

Contains(string, string, CompareOptions)

Checks whether a phrase contains a specified value using a comparison option.

public static bool Contains(this string phrase, string value, CompareOptions compareOption)

Parameters

phrase string

The phrase to check.

value string

The value to find.

compareOption CompareOptions

The compare option.

Returns

bool

True if the phrase contains the value; otherwise, false.

IsBoolean(string)

Checks whether a string value is a boolean.

public static bool IsBoolean(this string value)

Parameters

value string

The value to check.

Returns

bool

True if safely parses to a boolean; otherwise, false.

IsDouble(string)

Checks whether a string value is a double.

public static bool IsDouble(this string value)

Parameters

value string

The value to check.

Returns

bool

True if safely parses to a double; otherwise, false.

IsFloat(string)

Checks whether a string value is a float.

public static bool IsFloat(this string value)

Parameters

value string

The value to check.

Returns

bool

True if safely parses to a float; otherwise, false.

IsInt(string)

Checks whether a string value is an integer.

public static bool IsInt(this string value)

Parameters

value string

The value to check.

Returns

bool

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.

public static bool IsLike(this string value, string likePattern)

Parameters

value string

The value to compare is like.

likePattern string

The wildcard like pattern to match on.

Returns

bool

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");

Exceptions

RegexMatchTimeoutException

Throw if a Regex time-out occurred.

IsNullOrWhiteSpace(string)

Indicates whether a specified string is null, empty, or consists only of white-space characters.

public static bool IsNullOrWhiteSpace(this string value)

Parameters

value string

The string to test.

Returns

bool

True if the value parameter is null or empty, or if value consists exclusively of white-space characters.