String Comparison And Alphabetic Order of Individual Characters

后端 未结 4 1141
死守一世寂寞
死守一世寂寞 2021-02-18 23:06

I have a question related to string comparison vs. character comparison.

Characters > and 0 (zero) have following decimal values 62

4条回答
  •  一向
    一向 (楼主)
    2021-02-19 00:06

    It sounds like what you want is the comparison to not use culture-specific rules. Have you tried StringComparison.Ordinal:

    Console.WriteLine( string.Compare( ">", "0", StringComparison.Ordinal ) ); // returns a positive number
    

提交回复
热议问题