c# - 比较两个字符串[]

标签 c# asp.net

<分区>

在这里给我一个错误:

string.Compare(list[], list1[],true); <<<<<<

导致错误。

string[] list = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "v", "z" };
string[] list1 = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "v", "z" };

int result = string.Compare(list[], list1[], true);

if (result == 0)
{
    Label1.Text += "Two strings are equal";
}
else if (result == 1)
{
    Label1.Text += "Test String1 is greater than Test String2";
}
else if (result == -1)
{
    Label1.Text += "Test String1 is less than Test String2";
}

最佳答案

关于:

 bool areSame = list.SequenceEqual(list1);

关于c# - 比较两个字符串[],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6239154/

相关文章:

c# - LINQ 加入可空键

c# - 使用 linq 删除列表中的重复项

asp.net - 实时/生产 Web 应用程序中的错误跟踪

JavaScript 运行时错误 : Unable to get property 'length' of undefined or null reference

asp.net - 运行 ASP.NET Web 应用程序时找不到 System.Runtime 4.1.0.0

c# linq combine 2 字典

c# - Azure 应用服务 - .net 版本支持 - 更新(HTTP 500.31 错误)?

c# - 带有 NUnit 的 Microsoft PEX

c# - 处理程序映射的嵌套 WebAPI 问题(继承问题?)

javascript - 如何使用 jquery 将 xml 转换为 json