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

Commit f1c2993

Browse files
committed
System.Security: String.Compare -> String.Equals
Per the Best Practices for Using Strings at http://msdn.microsoft.com/en-us/library/dd465121(v=vs.110).aspx * Use an overload of the String.Equals method to test whether two strings are equal. * Use the String.Compare and String.CompareTo methods to sort strings, not to check for equality.
1 parent 40b6090 commit f1c2993

File tree

2 files changed

+4
-4
lines changed
  • src
    • System.Security.Cryptography.RSA/src/System/Security/Cryptography
    • System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates

2 files changed

+4
-4
lines changed

src/System.Security.Cryptography.RSA/src/System/Security/Cryptography/CapiHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static string UpgradeDSS(int dwProvType, string wszProvider)
3737
{
3838
string wszUpgrade = null;
3939
SafeProvHandle safeProvHandle = SafeProvHandle.InvalidHandle;
40-
if (string.Compare(wszProvider, MS_DEF_DSS_DH_PROV) == 0)
40+
if (string.Equals(wszProvider, MS_DEF_DSS_DH_PROV, StringComparison.Ordinal))
4141
{
4242
// If this is the base DSS/DH provider, see if we can use the enhanced provider instead.
4343
if (S_OK == AcquireCryptContext(ref safeProvHandle, null, MS_ENH_DSS_DH_PROV, dwProvType,
@@ -64,8 +64,8 @@ public static string UpgradeDSS(int dwProvType, string wszProvider)
6464
/// <returns>Returns upgrade CSP name</returns>
6565
public static string UpgradeRSA(int dwProvType, string wszProvider)
6666
{
67-
bool requestedEnhanced = (string.Compare(wszProvider, MS_ENHANCED_PROV) == 0);
68-
bool requestedBase = (string.Compare(wszProvider, MS_DEF_PROV) == 0);
67+
bool requestedEnhanced = string.Equals(wszProvider, MS_ENHANCED_PROV, StringComparison.Ordinal);
68+
bool requestedBase = string.Equals(wszProvider, MS_DEF_PROV, StringComparison.Ordinal);
6969
string wszUpgrade = null;
7070
SafeProvHandle safeProvHandle = SafeProvHandle.InvalidHandle;
7171
if (requestedBase || requestedEnhanced)

src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509ExtensionCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public X509Extension this[String oid]
5555
String oidValue = new Oid(oid).Value;
5656
foreach (X509Extension extension in _list)
5757
{
58-
if (String.Compare(extension.Oid.Value, oidValue, StringComparison.OrdinalIgnoreCase) == 0)
58+
if (String.Equals(extension.Oid.Value, oidValue, StringComparison.OrdinalIgnoreCase))
5959
return extension;
6060
}
6161
return null;

0 commit comments

Comments
 (0)