в то время как я учился (чтение Essential C#-5th Edition) метод String.Compare()
я прочитал, что если я позволяю сказать, что 1 строка text1
и 1 строка text2
при сравнении, что я получаю номер:string.Compare() 2 струнных
// 0 if equal
// negative if text1 < text2
// positive if text1 > text2
так, когда я это сделать
string text1 = "Hello";
string text2 = "Hello";
int result = string.Compare(text1, text2);
Console.Write(result); // I get 0 which means equal which is correct.
Но если я:
string text1 = "Helo";
string text2 = "Hello";
int result = string.Compare(text1, text2);
Console.Write(result); // I get 1. Shouldn't i be getting -1? Doing the opposite meaning that i have text1 = "Hello" and text 2 = "Helo" produces -1 when it should produce 1 correct?
Почему это происходит или мне не хватает (возиться) с чем-то?
Связанные http://stackoverflow.com/questions/9354966/string-sorting-issue-in-c-sharp – LibertyLocked
Вы видели словарь (как книга)? «Helo»> «Hello» ... –