String Comparison And Alphabetic Order of Individual Characters

后端 未结 4 1157
死守一世寂寞
死守一世寂寞 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:00

    The sort order of strings depends on the culture you use.

    StringComparer.CurrentCulture sorts the following 1-character strings as follows on my machine:

    ' -   ! " # $ % & (  ) * , . / : ; ? @ [
    \ ] ^ _ ` { | } ~ +  < = > 0 1 2 3 4 5 6
    7 8 9 a A b B c C d  D e E f F g G h H i
    I j J k K l L m M n  N o O p P q Q r R s
    S t T u U v V w W x  X y Y z Z
    

    StringComparer.Ordinal sorts the same strings as follows:

      ! " # $ % & ' ( )  * + , - . / 0 1 2 3
    4 5 6 7 8 9 : ; < =  > ? @ A B C D E F G
    H I J K L M N O P Q  R S T U V W X Y Z [
    \ ] ^ _ ` a b c d e  f g h i j k l m n o
    p q r s t u v w x y  z { | } ~
    

提交回复
热议问题