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
oldValuestringThe string value to be replaced.
newValuestringThe 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
otherStringReplacePairAn object to compare with this object.
Returns
- bool
trueif 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
valuestringThe string value to perform the sweep on.
fragmentschar[]The fragments containing the characters and/or words to delete.
Returns
- string
A new string that is equivalent to
valueexcept 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
valuestringThe string value to perform the sweep on.
comparisonStringComparisonOne of the enumeration values that specifies the rules to use in the comparison.
fragmentsstring[]The fragments containing the characters and/or words to delete.
Returns
- string
A new string that is equivalent to
valueexcept 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
valuestringThe string value to perform the sweep on.
fragmentsstring[]The fragments containing the characters and/or words to delete.
Returns
- string
A new string that is equivalent to
valueexcept 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
sourcestring[]The string[] value to perform the sweep on.
comparisonStringComparisonOne of the enumeration values that specifies the rules to use in the comparison.
fragmentsstring[]The fragments containing the characters and/or words to delete.
Returns
- string[]
A new string array that is equivalent to
sourceexcept 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
sourcestring[]The string[] value to perform the sweep on.
fragmentsstring[]The fragments containing the characters and/or words to delete.
Returns
- string[]
A new string array that is equivalent to
sourceexcept 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
valuestringThe string value to perform the replacement on.
replacePairsIEnumerable<StringReplacePair>A sequence of StringReplacePair values.
comparisonStringComparisonOne of the enumeration values that specifies the rules to use in the comparison. Default is OrdinalIgnoreCase.
Returns
Exceptions
- ArgumentNullException
valueis null -or-replacePairsis 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
valuestringThe string value to perform the replacement on.
oldValuestringThe string value to be replaced.
newValuestringThe string value to replace all occurrences of
oldValue.comparisonStringComparisonOne of the enumeration values that specifies the rules to use in the comparison. Default is OrdinalIgnoreCase.
Returns
Exceptions
- ArgumentNullException
valueis null -or-oldValueis 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
replacePair1StringReplacePairThe first date interval to compare.
replacePair2StringReplacePairThe second date interval to compare.
Returns
- bool
trueif the values ofreplacePair1andreplacePair2are equal; otherwise, false.
operator !=(StringReplacePair, StringReplacePair)
Indicates whether two DateSpan instances are not equal.
public static bool operator !=(StringReplacePair replacePair1, StringReplacePair replacePair2)
Parameters
replacePair1StringReplacePairThe first date interval to compare.
replacePair2StringReplacePairThe second date interval to compare.
Returns
- bool
trueif the values ofreplacePair1andreplacePair2are not equal; otherwise, false.