有两种方法:
1. 都转换成小写或者大写,在比较
string a = "C";
string b = "c";
a = a.ToLower();
b = b.ToLower();
if (a == b)
{
Console.WriteLine("一样!");
}
2.
string a = "C";
string b = "c";
if (a.Equals(b, StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine("一样!");
} |