C# 字符串比较方法

引用:http://www.cnblogs.com/sicket/archive/2010/10/18/1853950.html

用C#比较字符串有多种方法,如:

1. string.Compare(x,y);

2. string.Equals(x,y) ;

如果要不区分大小写进行比较,则对应为: string.Compare(x,y); string.Equals(x,y);

注:string.Compare比较结果的含义:

含义

小于零

x 小于 y。 或 x 为 空引用(在 Visual Basic 中为 Nothing)。

x 等于 y

大于零

x 大于 y。 或 y 为 空引用(在 Visual Basic 中为 Nothing)。

string.Equals比较结果的含义为:

含义

true

x 等于 y

false

x 不等 y


原文地址:https://www.cnblogs.com/zhangxp1129/p/2674704.html