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 string NewValue { get; }

Property Value

string

The string value to replace all occurrences of OldValue.

OldValue

Gets the string value to be replaced.

public 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 bool Equals(StringReplacePair other)

Parameters

other StringReplacePair

An object to compare with this object.

Returns

bool

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 bool Equals(object obj)

Parameters

obj object

The Object to compare with this instance.

Returns

bool

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

GetHashCode()

Returns a hash code for this instance.

public override int GetHashCode()

Returns

int

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

RemoveAll(string, params 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, StringComparison, params 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, params 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, params 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.

RemoveAll(string[], params 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.

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 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

operator ==(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

bool

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

operator !=(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

bool

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