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
stringThe string value to be replaced.
newValue
stringThe string value to replace all occurrences of
oldValue
.
Properties
NewValue
public string NewValue { get; }
Property Value
OldValue
Gets the string value to be replaced.
public string OldValue { get; }
Property Value
Methods
Equals(StringReplacePair)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(StringReplacePair other)
Parameters
other
StringReplacePairAn 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
Returns
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
stringThe 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
stringThe string value to perform the sweep on.
comparison
StringComparisonOne 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
stringThe 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
StringComparisonOne 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)
public static string ReplaceAll(string value, IEnumerable<StringReplacePair> replacePairs, StringComparison comparison = StringComparison.OrdinalIgnoreCase)
Parameters
value
stringThe string value to perform the replacement on.
replacePairs
IEnumerable<StringReplacePair>A sequence of StringReplacePair values.
comparison
StringComparisonOne of the enumeration values that specifies the rules to use in the comparison. Default is OrdinalIgnoreCase.
Returns
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
stringThe string value to perform the replacement on.
oldValue
stringThe string value to be replaced.
newValue
stringThe string value to replace all occurrences of
oldValue
.comparison
StringComparisonOne of the enumeration values that specifies the rules to use in the comparison. Default is OrdinalIgnoreCase.
Returns
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
StringReplacePairThe first date interval to compare.
replacePair2
StringReplacePairThe second date interval to compare.
Returns
- bool
true
if the values ofreplacePair1
andreplacePair2
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
StringReplacePairThe first date interval to compare.
replacePair2
StringReplacePairThe second date interval to compare.
Returns
- bool
true
if the values ofreplacePair1
andreplacePair2
are not equal; otherwise, false.