各位大哥
小弟正在努力學習C#中﹐關于字符串的比較的問題想請教各位大哥我知道 ﹐比較字符可以用compare方法﹐如﹕
class Program
{
static void Main(string[] args)
{
string str1 = "hello";
string str2 = "world";
Console.WriteLine("result:{0}",String.Compare(str1,str2));
}
}
可不用Compare﹐怎么去實現比較呢﹖希望大哥們不嗇賜教
小弟正在努力學習C#中﹐關于字符串的比較的問題想請教各位大哥我知道 ﹐比較字符可以用compare方法﹐如﹕
class Program
{
static void Main(string[] args)
{
string str1 = "hello";
string str2 = "world";
Console.WriteLine("result:{0}",String.Compare(str1,str2));
}
}
可不用Compare﹐怎么去實現比較呢﹖希望大哥們不嗇賜教
...
零 此实例等于 strB。
大于零 此实例大于 strB。
class Program
{
static void Main(string[] args)
{
string str1 = "hello";
string str2 = "world";
Console.WriteLine("result:{0}",str1.CompareTo(str2));
}
}