String类中IndexOf与SubString

说明:

value
类型:System..::.String

要查找的 String

startIndex
类型:System..::.Int32

搜索起始位置。

count
类型:System..::.Int32

要检查的字符位置数。

返回值

类型:System..::.Int32

如果找到该字符串,则为 value 的从零开始的索引位置;如果未找到该字符串,则为 -1。如果 valueEmpty,则返回值为 startIndex。 

SubString


参数

startIndex
类型:System..::.Int32

此实例中子字符串的起始字符位置(从零开始)。

length
类型:System..::.Int32

子字符串中的字符数。

返回值

类型:System..::.String

一个 String,它等于此实例中从 startIndex 开始的长度为 length 的子字符串,如果 startIndex 等于此实例的长度且 length 为零,则为 Empty

PS:

从MSDN上复制过来。最近在制作一个字符串处理的功能,时常用到此方法

原文地址:https://www.cnblogs.com/s380774061/p/2483313.html