c# - Inserting spaces between chars of two strings modify their order -
this question has answer here: unexpected behavior when sorting strings letters , dashes 2 answers i have 2 strings of same length. assuming (probably wrongly) inserting space between each character of each string not change order. var e1 = "12*4"; var e2 = "12-4"; console.writeline(string.compare(e1,e2)); // -1 (e1 < e2) var f1 = "1 2 * 4"; var f2 = "1 2 - 4"; console.writeline(string.compare(f1,f2)); // +1 (f1 > f2) if insert other characters (_ x instance), order preserved. what's going on ? thanks in advance. if use ordinal comparison, right result. the reason ordinal comparison works evaluating numeric value of each of chars in string object, inserting spaces make no difference. if use other types of comparisons, there other things involved. documentation: an operation uses w...