Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit a24f196

Browse files
justinvpjkotas
authored andcommitted
Use string.Contains(char) instead of Contains(string) (#15740)
Now that string.Contains(char) exists, use it in corelib.
1 parent 391be01 commit a24f196

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/mscorlib/shared/System/Globalization/CultureData.Unix.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private unsafe bool InitCultureData()
3333
string realNameBuffer = _sRealName;
3434

3535
// Basic validation
36-
if (realNameBuffer.Contains("@"))
36+
if (realNameBuffer.Contains('@'))
3737
{
3838
return false; // don't allow ICU variants to come in directly
3939
}
@@ -43,7 +43,7 @@ private unsafe bool InitCultureData()
4343
if (index > 0)
4444
{
4545
if (index >= (realNameBuffer.Length - 1) // must have characters after _
46-
|| realNameBuffer.Substring(index + 1).Contains("_")) // only one _ allowed
46+
|| realNameBuffer.Substring(index + 1).Contains('_')) // only one _ allowed
4747
{
4848
return false; // fail
4949
}

src/mscorlib/shared/System/Reflection/AssemblyNameFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private static void AppendQuoted(this StringBuilder sb, string s)
9595

9696
//@todo: App-compat: You can use double or single quotes to quote a name, and Fusion (or rather the IdentityAuthority) picks one
9797
// by some algorithm. Rather than guess at it, I'll just use double-quote consistently.
98-
if (s != s.Trim() || s.Contains("\"") || s.Contains("\'"))
98+
if (s != s.Trim() || s.Contains('\"') || s.Contains('\''))
9999
needsQuoting = true;
100100

101101
if (needsQuoting)

src/mscorlib/src/System/TimeZoneInfo.Unix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ public static TimeZoneInfo FindSystemTimeZoneById(string id)
564564
{
565565
throw new ArgumentNullException(nameof(id));
566566
}
567-
else if (id.Length == 0 || id.Contains("\0"))
567+
else if (id.Length == 0 || id.Contains('\0'))
568568
{
569569
throw new TimeZoneNotFoundException(SR.Format(SR.TimeZoneNotFound_MissingData, id));
570570
}

src/mscorlib/src/System/TimeZoneInfo.Win32.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public static TimeZoneInfo FindSystemTimeZoneById(string id)
348348
{
349349
throw new ArgumentNullException(nameof(id));
350350
}
351-
else if (id.Length == 0 || id.Length > MaxKeyLength || id.Contains("\0"))
351+
else if (id.Length == 0 || id.Length > MaxKeyLength || id.Contains('\0'))
352352
{
353353
throw new TimeZoneNotFoundException(SR.Format(SR.TimeZoneNotFound_MissingData, id));
354354
}

0 commit comments

Comments
 (0)