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 readonly string NewValue { get; }
Property Value
OldValue
Gets the String value to be replaced.
public readonly string OldValue { get; }
Property Value
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
StringReplacePairAn 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
Returns
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
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, 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, 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[], 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
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.
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 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
StringReplacePairThe first date interval to compare.
replacePair2
StringReplacePairThe second date interval to compare.
Returns
- Boolean
true
if the values ofreplacePair1
andreplacePair2
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
StringReplacePairThe first date interval to compare.
replacePair2
StringReplacePairThe second date interval to compare.
Returns
- Boolean
true
if the values ofreplacePair1
andreplacePair2
are not equal; otherwise, false.