Int Compare(string strA, string strB) Int Compare(string strA, string strB, bool ignoreCase) Int Compare(string strA, string strB, bool ignoreCase, CultureInfo) Int Compare(string strA, int indexA, string strB, int indexB, int length) Int Compare(string strA, int indexA, string strB, int indexB, int length, bool ignoreCase)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string strA = "你好"; string strB = "你好吗"; // 字符串比较 Console.WriteLine(string.Compare(strA, strB)); Console.WriteLine(string.Compare(strA, strA)); Console.WriteLine(string.Compare(strB, strA)); } } }输出:
string strA = "你好"; string strB = "你好吗"; Console.WriteLine(strA.CompareTo(strB));
string strA = "你好"; string strB = "你好吗"; Console.WriteLine(string.Equals(strA, strB)); Console.WriteLine(strA.Equals(strB));
原文地址:http://blog.csdn.net/crazygolf/article/details/38945497