12 private readonly
string value;
13 private readonly
string lowerCase;
14 private string upperCase;
23 this.lowerCase =
Value?.ToLower();
29 public string Value =>
this?.value;
43 if (this.upperCase is
null)
44 this.upperCase = this.value?.ToUpper();
46 return this.upperCase;
53 return this.value ??
string.Empty;
62 return this.lowerCase?.GetHashCode() ?? 0;
74 public override bool Equals(
object obj)
77 return this.lowerCase?.Equals(S?.lowerCase) ?? (S.lowerCase is
null);
78 else if (obj is
string S2)
79 return this.lowerCase?.Equals(S2?.ToLower()) ?? (S2 is
null);
81 return this.lowerCase is
null;
101 return this.lowerCase?.CompareTo(other.lowerCase) ?? (other.lowerCase is
null ? 0 : -1);
120 return this.lowerCase?.CompareTo(S.lowerCase) ?? (S.lowerCase is
null ? 0 : -1);
121 else if (obj is
string S2)
122 return this.lowerCase?.CompareTo(S2?.ToLower()) ?? (S2 is
null ? 0 : -1);
123 else if (obj is
null)
124 return this.lowerCase is
null ? 0 : 1;
154 return S1?.lowerCase == S2?.lowerCase;
162 return S1?.lowerCase != S2?.lowerCase;
170 return string.Compare(S1?.lowerCase, S2?.lowerCase) < 0;
178 return string.Compare(S1?.lowerCase, S2?.lowerCase) > 0;
186 return string.Compare(S1?.lowerCase, S2?.lowerCase) <= 0;
194 return string.Compare(S1?.lowerCase, S2?.lowerCase) >= 0;
202 return S1?.lowerCase == S2?.ToLower();
210 return S1?.lowerCase != S2?.ToLower();
218 return string.Compare(S1?.lowerCase, S2?.ToLower()) < 0;
226 return string.Compare(S1?.lowerCase, S2?.ToLower()) > 0;
234 return string.Compare(S1?.lowerCase, S2?.ToLower()) <= 0;
242 return string.Compare(S1?.lowerCase, S2?.ToLower()) >= 0;
250 return string.Compare(S1, S2?.lowerCase,
true) == 0;
258 return string.Compare(S1, S2?.lowerCase,
true) != 0;
266 return string.Compare(S1, S2?.lowerCase,
true) < 0;
274 return string.Compare(S1, S2?.lowerCase,
true) > 0;
282 return string.Compare(S1, S2?.lowerCase,
true) <= 0;
290 return string.Compare(S1, S2?.lowerCase,
true) >= 0;
306 return S1?.value + S2;
314 return S1 + S2?.value;
328 : this(new string(value))
342 : this(new string(c, count))
362 : this(new string(value, startIndex, length))
377 public char this[
int index] => this.value[index];
402 return string.Compare(strA.lowerCase, strB.lowerCase);
433 return string.Compare(strA.lowerCase, indexA, strB.lowerCase, indexB, length, comparisonType);
469 return string.Compare(strA.lowerCase, indexA, strB.lowerCase, indexB, length);
500 return string.Compare(strA.lowerCase, strB.lowerCase, comparisonType);
536 return string.CompareOrdinal(strA.lowerCase, indexA, strB.lowerCase, indexB, length);
557 return string.CompareOrdinal(strA.lowerCase, strB.lowerCase);
710 return Concat<CaseInsensitiveString>(values);
776 return string.Equals(a?.lowerCase, b?.lowerCase, comparisonType);
794 return string.Equals(a?.lowerCase, b?.lowerCase);
1047 return string.IsNullOrEmpty(value?.value);
1063 return string.IsNullOrWhiteSpace(value?.value);
1214 return this.lowerCase.Contains(value.lowerCase);
1244 public void CopyTo(
int sourceIndex,
char[] destination,
int destinationIndex,
int count)
1246 this.value.CopyTo(sourceIndex, destination, destinationIndex, count);
1270 return this.lowerCase.EndsWith(value.lowerCase, comparisonType);
1287 return this.lowerCase.EndsWith(value.lowerCase);
1303 return this.lowerCase?.Equals(value?.lowerCase) ?? value is
null;
1326 return this.lowerCase?.Equals(value?.lowerCase, comparisonType) ?? value is
null;
1352 return this.lowerCase.IndexOf(value.lowerCase, comparisonType);
1389 return this.lowerCase.IndexOf(value.lowerCase, startIndex, count, comparisonType);
1419 return this.lowerCase.IndexOf(value.lowerCase, startIndex, count);
1444 return this.lowerCase.IndexOf(value.lowerCase, startIndex);
1463 return this.lowerCase.IndexOf(value.lowerCase);
1488 public int IndexOf(
char value,
int startIndex,
int count)
1490 return this.lowerCase.IndexOf(
char.ToLower(value), startIndex, count);
1512 return this.lowerCase.IndexOf(
char.ToLower(value), startIndex);
1544 return this.lowerCase.IndexOf(value.lowerCase, startIndex, comparisonType);
1560 return this.lowerCase.IndexOf(
char.ToLower(value));
1590 return this.lowerCase.IndexOfAny(ToLower(anyOf), startIndex, count);
1593 private static char[] ToLower(
char[] A)
1595 int i, c = A.Length;
1597 A = (
char[])A.Clone();
1599 for (i = 0; i < c; i++)
1600 A[i] =
char.ToLower(A[i]);
1629 return this.lowerCase.IndexOfAny(ToLower(anyOf), startIndex);
1648 return this.lowerCase.IndexOfAny(ToLower(anyOf));
1660 int Result =
int.MaxValue;
1661 int i, j, c = anyOf.
Length;
1664 for (i = 0; i < c; i++)
1666 j = this.lowerCase.IndexOf(anyOf[i].lowerCase, startIndex, count);
1667 if (j >= 0 && j < Result)
1671 count = j - startIndex;
1742 return this.lowerCase.LastIndexOf(
char.ToLower(value));
1767 return this.lowerCase.LastIndexOf(
char.ToLower(value), startIndex);
1798 return this.lowerCase.LastIndexOf(
char.ToLower(value), startIndex, count);
1818 return this.lowerCase.LastIndexOf(value.lowerCase);
1850 return this.lowerCase.LastIndexOf(value.lowerCase, startIndex);
1889 return this.lowerCase.LastIndexOf(value.lowerCase, startIndex, count);
1935 return this.lowerCase.LastIndexOf(value.lowerCase, startIndex, count, comparisonType);
1975 return this.lowerCase.LastIndexOf(value.lowerCase, startIndex, comparisonType);
2002 return this.lowerCase.LastIndexOf(value.lowerCase, comparisonType);
2021 return this.lowerCase.LastIndexOfAny(ToLower(anyOf));
2051 return this.lowerCase.LastIndexOfAny(ToLower(anyOf), startIndex);
2085 return this.lowerCase.LastIndexOfAny(ToLower(anyOf), startIndex, count);
2252 string s = this.value;
2253 string s2 = this.lowerCase;
2254 int i = s2.
IndexOf(oldValue.lowerCase);
2261 s = s.Remove(i + Diff, c);
2262 s = s.Insert(i + Diff, newValue?.value);
2264 i = s2.IndexOf(oldValue.lowerCase, i + c);
2288 string s = this.value.
Replace(oldChar, newChar);
2289 char ch =
char.ToLower(oldChar);
2292 s = s.Replace(ch,
char.ToLower(newChar));
2294 s = s.Replace(
char.ToUpper(oldChar),
char.ToUpper(newChar));
2314 return this.
Split(separator,
int.MaxValue, StringSplitOptions.None);
2339 return this.
Split(separator, count, StringSplitOptions.None);
2372 char[] A = ToLower(separator);
2373 int i = this.lowerCase.IndexOfAny(A);
2378 while (i >= 0 && count > 0)
2380 s = this.value.Substring(Last + 1, i - Last - 1);
2382 if (options != StringSplitOptions.RemoveEmptyEntries || !
string.IsNullOrEmpty(s))
2389 i = this.lowerCase.IndexOfAny(A, i + 1);
2394 s = this.value.Substring(Last + 1);
2396 if (options != StringSplitOptions.RemoveEmptyEntries || !
string.IsNullOrEmpty(s))
2427 return this.
Split(separator,
int.MaxValue, options);
2464 while (i >= 0 && count > 0)
2466 s = this.value.Substring(Last + 1, i - Last - 1);
2468 if (options != StringSplitOptions.RemoveEmptyEntries || !
string.IsNullOrEmpty(s))
2480 s = this.value.Substring(Last + 1);
2482 if (options != StringSplitOptions.RemoveEmptyEntries || !
string.IsNullOrEmpty(s))
2513 return this.
Split(separator,
int.MaxValue, options);
2531 return this.lowerCase.StartsWith(value.lowerCase);
2555 return this.lowerCase.StartsWith(value.lowerCase, comparisonType);
2622 return this.value.ToCharArray(startIndex, length);
2635 return this.value.ToCharArray();
2671 private static char[] UpperAndLowerCases(
char[] trimChars)
2674 int i, c = trimChars.Length;
2677 for (i = 0; i < c; i++)
2682 ch2 =
char.ToLower(ch);
2686 ch2 =
char.ToUpper(ch);
Represents a case-insensitive string.
bool StartsWith(CaseInsensitiveString value, StringComparison comparisonType)
Determines whether the beginning of this string instance matches the specified string when compared u...
int IndexOf(char value, int startIndex)
Reports the zero-based index of the first occurrence of the specified Unicode character in this strin...
int LastIndexOf(CaseInsensitiveString value, int startIndex, StringComparison comparisonType)
Reports the zero-based index of the last occurrence of a specified string within the current System....
string Value
String-representation of the case-insensitive string. (Representation is case sensitive....
static bool operator==(CaseInsensitiveString S1, CaseInsensitiveString S2)
Equality operator
static bool operator<(CaseInsensitiveString S1, CaseInsensitiveString S2)
Lesser-than operator
static CaseInsensitiveString Concat< T >(IEnumerable< T > values)
Concatenates the members of an System.Collections.Generic.IEnumerable`1 implementation.
bool Equals(CaseInsensitiveString value, StringComparison comparisonType)
Determines whether this string and a specified System.CaseInsensitiveString object have the same valu...
CaseInsensitiveString Trim(params char[] trimChars)
Removes all leading and trailing occurrences of a set of characters specified in an array from the cu...
static readonly CaseInsensitiveString Empty
Empty case-insensitive string
int LastIndexOf(CaseInsensitiveString value)
Reports the zero-based index position of the last occurrence of a specified string within this instan...
bool Contains(CaseInsensitiveString value)
Returns a value indicating whether a specified substring occurs within this string.
CaseInsensitiveString TrimStart(params char[] trimChars)
Removes all leading occurrences of a set of characters specified in an array from the current System....
int IndexOfAny(CaseInsensitiveString[] anyOf)
Checks for the first occurrence of the case-insensitive strings in anyOf .
static CaseInsensitiveString Join(CaseInsensitiveString separator, CaseInsensitiveString[] value, int startIndex, int count)
Concatenates the specified elements of a string array, using the specified separator between each ele...
static CaseInsensitiveString Format(IFormatProvider provider, CaseInsensitiveString format, object arg0)
Replaces the format item or items in a specified string with the string representation of the corresp...
int LastIndexOfAny(char[] anyOf, int startIndex)
Reports the zero-based index position of the last occurrence in this instance of one or more characte...
CaseInsensitiveString PadRight(int totalWidth)
Returns a new string that left-aligns the characters in this string by padding them with spaces on th...
int Length
Gets the number of characters in the current CaseInsensitiveString object.
CaseInsensitiveString[] Split(CaseInsensitiveString[] separator, int count, StringSplitOptions options)
Returns a string array that contains the substrings in this string that are delimited by elements of ...
static CaseInsensitiveString Format(CaseInsensitiveString format, object arg0)
Replaces one or more format items in a specified string with the string representation of a specified...
static CaseInsensitiveString Concat(object arg0)
Creates the string representation of a specified object.
string LowerCase
Lower-case representation of the case-insensitive string.
CaseInsensitiveString PadLeft(int totalWidth, char paddingChar)
Returns a new string that right-aligns the characters in this instance by padding them on the left wi...
bool Equals(CaseInsensitiveString value)
Determines whether this instance and another specified System.CaseInsensitiveString object have the s...
CaseInsensitiveString(string Value)
Represents a case-insensitive string.
int IndexOf(CaseInsensitiveString value, StringComparison comparisonType)
Reports the zero-based index of the first occurrence of the specified string in the current System....
CaseInsensitiveString PadRight(int totalWidth, char paddingChar)
Returns a new string that left-aligns the characters in this string by padding them on the right with...
int IndexOf(char value, int startIndex, int count)
Reports the zero-based index of the first occurrence of the specified character in this instance....
CaseInsensitiveString PadLeft(int totalWidth)
Returns a new string that right-aligns the characters in this instance by padding them with spaces on...
int LastIndexOf(char value)
Reports the zero-based index position of the last occurrence of a specified Unicode character within ...
static bool operator>=(CaseInsensitiveString S1, CaseInsensitiveString S2)
Greater-than-or-equal-to operator
static bool IsNullOrEmpty(CaseInsensitiveString value)
Indicates whether the specified string is null or an CaseInsensitiveString.Empty string.
static CaseInsensitiveString Format(CaseInsensitiveString format, params object[] args)
Replaces the format item in a specified string with the string representation of a corresponding obje...
int IndexOfAny(char[] anyOf)
Reports the zero-based index of the first occurrence in this instance of any character in a specified...
static bool Equals(CaseInsensitiveString a, CaseInsensitiveString b, StringComparison comparisonType)
Determines whether two specified System.CaseInsensitiveString objects have the same value....
static CaseInsensitiveString operator+(CaseInsensitiveString S1, CaseInsensitiveString S2)
Addition operator
static int Compare(CaseInsensitiveString strA, int indexA, CaseInsensitiveString strB, int indexB, int length, StringComparison comparisonType)
Compares substrings of two specified CaseInsensitiveString objects using the specified rules,...
int LastIndexOf(char value, int startIndex)
Reports the zero-based index position of the last occurrence of a specified Unicode character within ...
CaseInsensitiveString Replace(char oldChar, char newChar)
Returns a new string in which all occurrences of a specified Unicode character in this instance are r...
int IndexOf(CaseInsensitiveString value)
Reports the zero-based index of the first occurrence of the specified string in this instance.
CaseInsensitiveString TrimEnd(params char[] trimChars)
Removes all trailing occurrences of a set of characters specified in an array from the current System...
CaseInsensitiveString[] Split(char[] separator, int count)
Returns a string array that contains the substrings in this instance that are delimited by elements o...
static CaseInsensitiveString Format(IFormatProvider provider, CaseInsensitiveString format, params object[] args)
Replaces the format items in a specified string with the string representations of corresponding obje...
int LastIndexOfAny(char[] anyOf, int startIndex, int count)
Reports the zero-based index position of the last occurrence in this instance of one or more characte...
static CaseInsensitiveString Concat(CaseInsensitiveString str0, CaseInsensitiveString str1, CaseInsensitiveString str2)
Concatenates three specified instances of CaseInsensitiveString.
static CaseInsensitiveString Join(CaseInsensitiveString separator, IEnumerable< CaseInsensitiveString > values)
Concatenates the members of a constructed System.Collections.Generic.IEnumerable`1 collection of type...
int IndexOf(char value)
Reports the zero-based index of the first occurrence of the specified Unicode character in this strin...
CaseInsensitiveString[] Split(char[] separator, StringSplitOptions options)
Returns a string array that contains the substrings in this string that are delimited by elements of ...
CaseInsensitiveString Trim()
Removes all leading and trailing white-space characters from the current CaseInsensitiveString object...
static int Compare(CaseInsensitiveString strA, CaseInsensitiveString strB, StringComparison comparisonType)
Compares two specified CaseInsensitiveString objects using the specified rules, and returns an intege...
int CompareTo(CaseInsensitiveString other)
Compares this instance with a specified System.CaseInsensitiveString object and indicates whether thi...
CaseInsensitiveString(char[] value)
Initializes a new instance of the CaseInsensitiveString class to the value indicated by an array of U...
void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
Copies a specified number of characters from a specified position in this instance to a specified pos...
CaseInsensitiveString Replace(CaseInsensitiveString oldValue, CaseInsensitiveString newValue)
Returns a new string in which all occurrences of a specified string in the current instance are repla...
CaseInsensitiveString Remove(int startIndex)
Returns a new string in which all the characters in the current instance, beginning at a specified po...
static int CompareOrdinal(CaseInsensitiveString strA, int indexA, CaseInsensitiveString strB, int indexB, int length)
Compares substrings of two specified CaseInsensitiveString objects by evaluating the numeric values o...
static CaseInsensitiveString Join(CaseInsensitiveString separator, params CaseInsensitiveString[] value)
Concatenates all the elements of a string array, using the specified separator between each element.
string UpperCase
Upper-case representation of the case-insensitive string.
int LastIndexOf(CaseInsensitiveString value, int startIndex, int count, StringComparison comparisonType)
Reports the zero-based index position of the last occurrence of a specified string within this instan...
static bool operator<=(CaseInsensitiveString S1, CaseInsensitiveString S2)
Lesser-than-or-equal-to operator
CaseInsensitiveString(char[] value, int startIndex, int length)
Initializes a new instance of the CaseInsensitiveString class to the value indicated by an array of U...
CaseInsensitiveString[] Split(CaseInsensitiveString[] separator, StringSplitOptions options)
Returns a string array that contains the substrings in this string that are delimited by elements of ...
int LastIndexOfAny(char[] anyOf)
Reports the zero-based index position of the last occurrence in this instance of one or more characte...
static CaseInsensitiveString Format(IFormatProvider provider, CaseInsensitiveString format, object arg0, object arg1, object arg2)
Replaces the format items in a specified string with the string representation of three specified obj...
bool StartsWith(CaseInsensitiveString value)
Determines whether the beginning of this string instance matches the specified string.
static bool IsNullOrWhiteSpace(CaseInsensitiveString value)
Indicates whether a specified string is null, empty, or consists only of white-space characters.
static CaseInsensitiveString Join(CaseInsensitiveString separator, params object[] values)
Concatenates the elements of an object array, using the specified separator between each element.
CaseInsensitiveString[] Split(params char[] separator)
Returns a string array that contains the substrings in this instance that are delimited by elements o...
static CaseInsensitiveString Concat(object arg0, object arg1)
Concatenates the string representations of two specified objects.
CaseInsensitiveString Insert(int startIndex, CaseInsensitiveString value)
Returns a new string in which a specified string is inserted at a specified index position in this in...
override int GetHashCode()
Returns the hash code for this string.
static int Compare(CaseInsensitiveString strA, CaseInsensitiveString strB)
Compares two specified CaseInsensitiveString objects and returns an integer that indicates their rela...
static bool operator>(CaseInsensitiveString S1, CaseInsensitiveString S2)
Greater-than operator
char[] ToCharArray()
Copies the characters in this instance to a Unicode character array.
static CaseInsensitiveString Format(CaseInsensitiveString format, object arg0, object arg1)
Replaces the format items in a specified string with the string representation of two specified objec...
int IndexOf(CaseInsensitiveString value, int startIndex)
Reports the zero-based index of the first occurrence of the specified string in this instance....
int LastIndexOf(char value, int startIndex, int count)
Reports the zero-based index position of the last occurrence of the specified Unicode character in a ...
static CaseInsensitiveString Concat(CaseInsensitiveString str0, CaseInsensitiveString str1)
Concatenates two specified instances of CaseInsensitiveString.
CaseInsensitiveString Substring(int startIndex)
Retrieves a substring from this instance. The substring starts at a specified character position and ...
int LastIndexOf(CaseInsensitiveString value, int startIndex, int count)
Reports the zero-based index position of the last occurrence of a specified string within this instan...
int IndexOf(CaseInsensitiveString value, int startIndex, StringComparison comparisonType)
Reports the zero-based index of the first occurrence of the specified string in the current System....
override string ToString()
int IndexOf(CaseInsensitiveString value, int startIndex, int count)
Reports the zero-based index of the first occurrence of the specified string in this instance....
static CaseInsensitiveString Concat(params object[] args)
Concatenates the string representations of the elements in a specified System.Object array.
int LastIndexOf(CaseInsensitiveString value, int startIndex)
Reports the zero-based index position of the last occurrence of a specified string within this instan...
int LastIndexOf(CaseInsensitiveString value, StringComparison comparisonType)
Reports the zero-based index of the last occurrence of a specified string within the current System....
static CaseInsensitiveString Format(CaseInsensitiveString format, object arg0, object arg1, object arg2)
Replaces the format items in a specified string with the string representation of three specified obj...
CaseInsensitiveString(char c, int count)
Initializes a new instance of the CaseInsensitiveString class to the value indicated by a specified U...
static int CompareOrdinal(CaseInsensitiveString strA, CaseInsensitiveString strB)
Compares two specified CaseInsensitiveString objects by evaluating the numeric values of the correspo...
static CaseInsensitiveString Concat(object arg0, object arg1, object arg2)
Concatenates the string representations of three specified objects.
int CompareTo(object obj)
Compares this instance with a specified System.CaseInsensitiveString object and indicates whether thi...
static CaseInsensitiveString Join< T >(CaseInsensitiveString separator, IEnumerable< T > values)
Concatenates the members of a collection, using the specified separator between each member.
CaseInsensitiveString Substring(int startIndex, int length)
Retrieves a substring from this instance. The substring starts at a specified character position and ...
int IndexOfAny(char[] anyOf, int startIndex)
Reports the zero-based index of the first occurrence in this instance of any character in a specified...
CaseInsensitiveString Remove(int startIndex, int count)
Returns a new string in which a specified number of characters in the current instance beginning at a...
int IndexOfAny(char[] anyOf, int startIndex, int count)
Reports the zero-based index of the first occurrence in this instance of any character in a specified...
static bool operator!=(CaseInsensitiveString S1, CaseInsensitiveString S2)
Non-Equality operator
override bool Equals(object obj)
Determines whether this instance and a specified object, which must also be a System....
static CaseInsensitiveString Format(IFormatProvider provider, CaseInsensitiveString format, object arg0, object arg1)
Replaces the format items in a specified string with the string representation of two specified objec...
int IndexOf(CaseInsensitiveString value, int startIndex, int count, StringComparison comparisonType)
Reports the zero-based index of the first occurrence of the specified string in the current System....
static CaseInsensitiveString Concat(IEnumerable< CaseInsensitiveString > values)
Concatenates the members of a constructed System.Collections.Generic.IEnumerable`1 collection of type...
bool EndsWith(CaseInsensitiveString value)
Determines whether the end of this string instance matches the specified string.
CaseInsensitiveString[] Split(char[] separator, int count, StringSplitOptions options)
Returns a string array that contains the substrings in this string that are delimited by elements of ...
static int Compare(CaseInsensitiveString strA, int indexA, CaseInsensitiveString strB, int indexB, int length)
Compares substrings of two specified CaseInsensitiveString objects and returns an integer that indica...
static CaseInsensitiveString Concat(CaseInsensitiveString str0, CaseInsensitiveString str1, CaseInsensitiveString str2, CaseInsensitiveString str3)
Concatenates four specified instances of CaseInsensitiveString.
char[] ToCharArray(int startIndex, int length)
Copies the characters in a specified substring in this instance to a Unicode character array.
static CaseInsensitiveString Concat(params CaseInsensitiveString[] values)
Concatenates the elements of a specified CaseInsensitiveString array.
int IndexOfAny(CaseInsensitiveString[] anyOf, int startIndex)
Checks for the first occurrence of the case-insensitive strings in anyOf .
bool EndsWith(CaseInsensitiveString value, StringComparison comparisonType)
Determines whether the end of this string instance matches the specified string when compared using t...
static bool Equals(CaseInsensitiveString a, CaseInsensitiveString b)
Determines whether two specified System.CaseInsensitiveString objects have the same value.
int IndexOfAny(CaseInsensitiveString[] anyOf, int startIndex, int count)
Checks for the first occurrence of the case-insensitive strings in anyOf .
A chunked list is a linked list of chunks of objects of type T .
void Add(T Item)
Adds an item to the collection.
T[] ToArray()
Returns an array containing all elements of the collection.