@@ -19,6 +19,16 @@ public bool Contains(string value, StringComparison comparisonType)
1919 return ( IndexOf ( value , comparisonType ) >= 0 ) ;
2020 }
2121
22+ public bool Contains ( char value )
23+ {
24+ return IndexOf ( value ) != - 1 ;
25+ }
26+
27+ public bool Contains ( char value , StringComparison comparisonType )
28+ {
29+ return IndexOf ( value , comparisonType ) != - 1 ;
30+ }
31+
2232 // Returns the index of the first occurrence of a specified character in the current instance.
2333 // The search starts at startIndex and runs thorough the next count characters.
2434 //
@@ -32,6 +42,33 @@ public int IndexOf(char value, int startIndex)
3242 return IndexOf ( value , startIndex , this . Length - startIndex ) ;
3343 }
3444
45+ public int IndexOf ( char value , StringComparison comparisonType )
46+ {
47+ switch ( comparisonType )
48+ {
49+ case StringComparison . CurrentCulture :
50+ return CultureInfo . CurrentCulture . CompareInfo . IndexOf ( this , value , CompareOptions . None ) ;
51+
52+ case StringComparison . CurrentCultureIgnoreCase :
53+ return CultureInfo . CurrentCulture . CompareInfo . IndexOf ( this , value , CompareOptions . IgnoreCase ) ;
54+
55+ case StringComparison . InvariantCulture :
56+ return CultureInfo . InvariantCulture . CompareInfo . IndexOf ( this , value , CompareOptions . None ) ;
57+
58+ case StringComparison . InvariantCultureIgnoreCase :
59+ return CultureInfo . InvariantCulture . CompareInfo . IndexOf ( this , value , CompareOptions . IgnoreCase ) ;
60+
61+ case StringComparison . Ordinal :
62+ return CultureInfo . InvariantCulture . CompareInfo . IndexOf ( this , value , CompareOptions . Ordinal ) ;
63+
64+ case StringComparison . OrdinalIgnoreCase :
65+ return CultureInfo . InvariantCulture . CompareInfo . IndexOf ( this , value , CompareOptions . OrdinalIgnoreCase ) ;
66+
67+ default :
68+ throw new ArgumentException ( SR . NotSupported_StringComparison , nameof ( comparisonType ) ) ;
69+ }
70+ }
71+
3572 public unsafe int IndexOf ( char value , int startIndex , int count )
3673 {
3774 if ( startIndex < 0 || startIndex > Length )
0 commit comments