Comparison of two lines []

enter me an error here:

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

causes an error.

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";
}
+3
source share
4 answers

Use SequenceEqual from Linq to check if string arrays are the same

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

+5
source

What about:

 bool areSame = list.SequenceEqual(list1);
+6
source

, string.Compare .

, , [] , .

SO- , , .

+2

string.Compare , .

.

You need to decide the behavior for different length arrays, what you need to return for different values ​​in the same index, etc.

+1
source

All Articles