diff options
Diffstat (limited to 'src/mscorlib/src/System/String.Manipulation.cs')
-rw-r--r-- | src/mscorlib/src/System/String.Manipulation.cs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mscorlib/src/System/String.Manipulation.cs b/src/mscorlib/src/System/String.Manipulation.cs index 33e341c58e..b71ffa2f63 100644 --- a/src/mscorlib/src/System/String.Manipulation.cs +++ b/src/mscorlib/src/System/String.Manipulation.cs @@ -1022,8 +1022,10 @@ namespace System { if (oldValue == null) throw new ArgumentNullException(nameof(oldValue)); + if (oldValue.Length == 0) + throw new ArgumentException(SR.Argument_StringZeroLength, nameof(oldValue)); - // If they asked to replace oldValue with a null, replace all occurences + // If they asked to replace oldValue with a null, replace all occurrences // with the empty string. if (newValue == null) newValue = string.Empty; @@ -1037,10 +1039,11 @@ namespace System int matchLength = 0; bool hasDoneAnyReplacements = false; + CompareInfo ci = referenceCulture.CompareInfo; do { - index = referenceCulture.CompareInfo.IndexOfCore(this, oldValue, startIndex, m_stringLength - startIndex, options, &matchLength); + index = ci.IndexOf(this, oldValue, startIndex, m_stringLength - startIndex, options, &matchLength); if (index >= 0) { // append the unmodified portion of string |