Show / Hide Table of Contents

Class StringExtensions

Class encapsulating extension for String class.

Inheritance
object
StringExtensions
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Sartorius.SAF.Extensions
Assembly: Sartorius.SAF.dll
Syntax
public static class StringExtensions

Methods

View Source

IsHexColor(string)

Determines whether this value is convertible to a hexadecimal color.

Declaration
public static bool IsHexColor(this string hexValue)
Parameters
Type Name Description
string hexValue

The hexadecimal value.

Returns
Type Description
bool

true if the given string could be converted to a hex color; false otherwise.

View Source

IsStringHex(string)

Determines whether the given string is a valid hexadecimal value

Declaration
public static bool IsStringHex(this string hexString)
Parameters
Type Name Description
string hexString

A string that potentially contains a hex value.

Returns
Type Description
bool

true if the given string could be converted to a hex number; false otherwise.

View Source

Replace(string, string, string, int)

Replaces the oldValue with the newValue starting at selectionStart.

Declaration
public static string Replace(this string str, string oldValue, string newValue, int selectionStart)
Parameters
Type Name Description
string str

The string.

string oldValue

The old value.

string newValue

The new value.

int selectionStart

Start of the selection.

Returns
Type Description
string

Returns a new string in which the oldValue was replaced by the newValue.

View Source

Search(string, string)

Returns a value indicating whether the specified String object occurs within this string using a wildcard search and the current culture for lexical comparison.

Declaration
[Pure]
public static bool Search(this string str, string value)
Parameters
Type Name Description
string str

The string.

string value

The value to search. This may contain wildcards, see examples

Returns
Type Description
bool

true if str starts with value or the wildcard pattern in value can be found in str, false otherwise.

Remarks

This method performs a case sensitive lexical search according to the CurrentCulture. The search begins at the first character position of this string and continues through the last character position. If value contains a wildcard pattern, the pattern is searched in str, see examples. Otherwise this method only returns true if the string starts with the value.

Valid wildcard patterns are ? to match zero or exactly one character and * to match zero or more characters.

Examples

This example illustrates how to use the Search(string, string) extension

This example illustrates how to use the Search(string, string) extension

This example illustrates how to use the Search(string, string) extension

View Source

Search(string, string, StringComparison)

Returns a value indicating whether the specified String object occurs within this string using a wildcard search using the specified StringComparison.

Declaration
[Pure]
public static bool Search(this string str, string value, StringComparison comparison)
Parameters
Type Name Description
string str

The string.

string value

The value to search.

StringComparison comparison

The StringComparison used for comparing. See remarks for further information.

Returns
Type Description
bool

true if str starts with value or the wildcard pattern in value can be found in str, false otherwise.

Remarks

This method performs a comparison according to the provided comparison. The search begins at the first character position of this string and continues through the last character position. If value contains a wildcard pattern, the pattern is searched in str, see examples. Otherwise this method only returns true if the string starts with the value.

Valid wildcard patterns are ? to match zero or exactly one character and * to match zero or more characters.

When using Ordinal or OrdinalIgnoreCase the search does not use wildcard patterns.

Examples

This example illustrates how to use the Search(string, string) extension

This example illustrates how to use the Search(string, string) extension

This example illustrates how to use the Search(string, string) extension

  • View Source
Back to top Generated by DocFX