比较两个字符串[]

Nic*_*ahn 3 c# asp.net

在这里给我一个错误:

string.Compare(list[], list1[],true); <<<<<<
Run Code Online (Sandbox Code Playgroud)

导致错误.

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";
}
Run Code Online (Sandbox Code Playgroud)

Lad*_*nka 6

关于什么:

 bool areSame = list.SequenceEqual(list1);
Run Code Online (Sandbox Code Playgroud)


Muh*_*han 5

使用Linq的SequenceEqual来检查字符串数组是否相同

http://msdn.microsoft.com/en-us/library/bb348567.aspx