StringComparison.InvariantCulture
for the
how
parameter in which case all
cultural differences are avoided. This approach is demonstrated by the following program:
// Compare strings using StringComparison enumeration.
using System;
class StrCompDemo {
static void Main() {
// Note: Never embed a password in real code.
// This is for demonstration purposes only.
string pswd = "we~23&blx$";
string str;
Console.WriteLine("Enter password: ");
str = Console.ReadLine();
// Compare using invariant culture.
if(String.Compare(pswd, str,
StringComparison.InvariantCulture) == 0)
Console.WriteLine("Password accepted.");
else
Console.WriteLine("Password invalid.");
}
}
Do'stlaringiz bilan baham: |