,而我是學習(閱讀基本C#6第五版)的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」>「你好」... –