Table of Contents

Struct StringReplacePair

Namespace
Cuemon
Assembly
Cuemon.Core.dll

Defines a oldValue/newValue pair that can be set or retrieved for string replace operations.

public readonly struct StringReplacePair

Constructors

StringReplacePair(String, String)

Initializes a new instance of the StringReplacePair struct.

public StringReplacePair(string oldValue, string newValue)

Parameters

oldValue String

The String value to be replaced.

newValue String

The String value to replace all occurrences of oldValue.

Properties

NewValue

Gets the String value to replace all occurrences of OldValue.

public readonly string NewValue { get; }

Property Value

String

The String value to replace all occurrences of OldValue.

OldValue

Gets the String value to be replaced.

public readonly string OldValue { get; }

Property Value

String

The String value to be replaced.

Methods

Equals(StringReplacePair)

Indicates whether the current object is equal to another object of the same type.

public readonly bool Equals(StringReplacePair other)

Parameters

other StringReplacePair

An object to compare with this object.

Returns

Boolean

true if the current object is equal to the other parameter; otherwise, false.

Equals(Object)

Determines whether the specified Object is equal to this instance.

public override readonly bool Equals(object obj)

Parameters

obj Object

The Object to compare with this instance.

Returns

Boolean

true if the specified Object is equal to this instance; otherwise, false.

GetHashCode()

Returns a hash code for this instance.

public override readonly int GetHashCode()

Returns

Int32

A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

RemoveAll(String, Char[])

Returns a new string in which all the specified fragments has been deleted from the specified value.

public static string RemoveAll(string value, params char[] fragments)

Parameters

value String

The String value to perform the sweep on.

fragments Char[]

The fragments containing the characters and/or words to delete.

Returns

String

A new string that is equivalent to value except for the removed characters.

RemoveAll(String, String[])

Returns a new string in which all the specified fragments has been removed from the specified value.

public static string RemoveAll(string value, params string[] fragments)

Parameters

value String

The String value to perform the sweep on.

fragments String[]

The fragments containing the characters and/or words to delete.

Returns

String

A new string that is equivalent to value except for the removed characters and/or words.

Remarks

This method performs an ordinal (case-sensitive and culture-insensitive) comparison. The search begins at the first character position of this string and continues through the last character position.

RemoveAll(String, StringComparison, String[])

Returns a new string in which all the specified fragments has been deleted from the specified value.

public static string RemoveAll(string value, StringComparison comparison, params string[] fragments)

Parameters

value String

The String value to perform the sweep on.

comparison StringComparison

One of the enumeration values that specifies the rules to use in the comparison.

fragments String[]

The fragments containing the characters and/or words to delete.

Returns

String

A new string that is equivalent to value except for the removed characters and/or words.

RemoveAll(String[], String[])

Returns a new string array in which all the specified fragments has been deleted from the specified source array.

public static string[] RemoveAll(string[] source, params string[] fragments)

Parameters

source String[]

The string[] value to perform the sweep on.

fragments String[]

The fragments containing the characters and/or words to delete.

Returns

String[]

A new string array that is equivalent to source except for the removed characters and/or words.

Remarks

This method performs an ordinal (case-sensitive and culture-insensitive) comparison. The search begins at the first character position of this string and continues through the last character position.

RemoveAll(String[], StringComparison, String[])

Returns a new string array in which all the specified fragments has been deleted from the specified source array.

public static string[] RemoveAll(string[] source, StringComparison comparison, params string[] fragments)

Parameters

source String[]

The string[] value to perform the sweep on.

comparison StringComparison

One of the enumeration values that specifies the rules to use in the comparison.

fragments String[]

The fragments containing the characters and/or words to delete.

Returns

String[]

A new string array that is equivalent to source except for the removed characters and/or words.

ReplaceAll(String, IEnumerable<StringReplacePair>, StringComparison)

Replaces all occurrences of the OldValue with NewValue of the replacePairs sequence in value.

public static string ReplaceAll(string value, IEnumerable<StringReplacePair> replacePairs, StringComparison comparison = StringComparison.OrdinalIgnoreCase)

Parameters

value String

The String value to perform the replacement on.

replacePairs IEnumerable<StringReplacePair>

A sequence of StringReplacePair values.

comparison StringComparison

One of the enumeration values that specifies the rules to use in the comparison. Default is OrdinalIgnoreCase.

Returns

String

A String equivalent to value but with all instances of OldValue replaced with NewValue.

Exceptions

ArgumentNullException

value is null -or- replacePairs is null.

ReplaceAll(String, String, String, StringComparison)

Replaces all occurrences of oldValue in value, with newValue.

public static string ReplaceAll(string value, string oldValue, string newValue, StringComparison comparison = StringComparison.OrdinalIgnoreCase)

Parameters

value String

The String value to perform the replacement on.

oldValue String

The String value to be replaced.

newValue String

The String value to replace all occurrences of oldValue.

comparison StringComparison

One of the enumeration values that specifies the rules to use in the comparison. Default is OrdinalIgnoreCase.

Returns

String

A String equivalent to value but with all instances of oldValue replaced with newValue.

Exceptions

ArgumentNullException

value is null -or- oldValue is null.

ToString()

Returns a string representation of the StringReplacePair, using the string representations of the oldValue and newValue.

public override readonly string ToString()

Returns

String

A string representation of the StringReplacePair, which includes the string representations of the oldValue and newValue.

Remarks

The string representation consists of the string representations of the oldValue and newValue, separated by a comma and a space, and enclosed in square brackets. For example, the ToString method for a StringReplacePair structure with the string OldValue "Test1" and the string NewValue "Test2" returns the string "[Test1, Test2]".

Operators

Equality(StringReplacePair, StringReplacePair)

Indicates whether two StringReplacePair instances are equal.

public static bool operator ==(StringReplacePair replacePair1, StringReplacePair replacePair2)

Parameters

replacePair1 StringReplacePair

The first date interval to compare.

replacePair2 StringReplacePair

The second date interval to compare.

Returns

Boolean

true if the values of replacePair1 and replacePair2 are equal; otherwise, false.

Inequality(StringReplacePair, StringReplacePair)

Indicates whether two DateSpan instances are not equal.

public static bool operator !=(StringReplacePair replacePair1, StringReplacePair replacePair2)

Parameters

replacePair1 StringReplacePair

The first date interval to compare.

replacePair2 StringReplacePair

The second date interval to compare.

Returns

Boolean

true if the values of replacePair1 and replacePair2 are not equal; otherwise, false.