String.Compare 方法 (String, Int32, String, Int32, Int32)
对两个指定的 String 对象的子字符串进行比较,并返回一个指示二者在排序顺序中的相对位置的整数。

参数
strA
类型:System.String
要在比较中使用的第一个字符串。
indexA
类型:System.Int32
strA 中子字符串的位置。
strB
类型:System.String
要在比较中使用的第二个字符串。
indexB
类型:System.Int32
strB 中子字符串的位置。
length
类型:System.Int32
要比较的子字符串中字符的最大数量。
返回值

类型:System.Int32
一个 32 位有符号整数,指示两个比较数之间的词法关系。

值                    Condition

小于零          strA 中的子字符串小于 strB 中的子字符串。

零                 子字符串相等,或者 length 为零。

大于零         strA 中的子字符串大于 strB 中的子字符串。

// Sample for String.Compare(String, Int32, String, Int32, Int32)
using System; class Sample {
public static void Main() {
// 0123456
String str1 = "machine";
String str2 = "device";
String str;
int result; Console.WriteLine();
Console.WriteLine("str1 = '{0}', str2 = '{1}'", str1, str2);
result = String.Compare(str1, 2, str2, 0, 2);
str = ((result < 0) ? "less than" : ((result > 0) ? "greater than" : "equal to"));
Console.Write("Substring '{0}' in '{1}' is ", str1.Substring(2, 2), str1);
Console.Write("{0} ", str);
Console.WriteLine("substring '{0}' in '{1}'.", str2.Substring(0, 2), str2);
}
}
/*
This example produces the following results: str1 = 'machine', str2 = 'device'
Substring 'ch' in 'machine' is less than substring 'de' in 'device'.
*/
http://msdn.microsoft.com/zh-cn/library/x7tax739.aspx

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

最新文章

  1. Struts2的模板和主题theme及自定义theme的使用
  2. Java基础(56):Java---Assertion的试用(华为OJ里的Java题目的用例检测就是用的断言)
  3. java 获取本机ip地址
  4. SSRS集成至Web
  5. linux环境下java读取sh脚本并执行
  6. 11个超棒的iOS开发学习网站
  7. &lt;Android基础&gt; (五) 广播机制
  8. NOIp2018爆零记
  9. [CC-CMPVIRS]Computer Virus
  10. 【iCore4 双核心板_uC/OS-II】例程六:信号量——任务同步
  11. Javascript定义变量
  12. Oracle11g ADG环境实施文档-1204
  13. EF Core中如何取消跟踪DbContext中所有被跟踪的实体
  14. k8s之使用secret获取私有仓库镜像
  15. Docker(五)-Dcoker容器
  16. 多目标线性规划求解方法及matlab实现
  17. Linux(RedHat) 开机时修改root密码
  18. Too Rich(贪心+DFS)
  19. 4013: [HNOI2015]实验比较
  20. CentOS基础命令大全

热门文章

  1. Redis 工具类
  2. mongodb工具类
  3. 初学python - 脚本文件
  4. boost::string 例题1
  5. maven+eclipse+ssm 环境搭建和启动
  6. 搭建sftp并设置不同权限的多个用户
  7. linux设置ip别名
  8. Determining the Size of a Class Object---sizeof(class)---By Girish Shetty
  9. P5108 仰望半月的夜空 SAM+线段树覆盖
  10. 使用maven搭建ssm框架的javaweb项目