报告指定的 String 在此实例中的第一个匹配项的索引。public int IndexOf( string value );参数value 要查找的 String。 返回值如果找到该字符,则为 value 的索引位置;如果未找到该字符,则为 -1。如果 value 为 Empty,则返回值为 0。
Microsoft .NET Framework 类库String 成员: http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/cpref/html/frlrfsystemstringmemberstopic.aspString.Substring 方法: http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/cpref/html/frlrfsystemstringclasssubstringtopic.aspString.IndexOf 方法: http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/cpref/html/frlrfsystemstringclassindexoftopic.asp
InStr() == IndexOf()
可能是这样
int startIndex,
int length
);参数startIndex
子字符串的起始位置的索引。 length
子字符串中的字符数。 返回值一个 String,等效于此实例中从 startIndex 开始的、长度为 length 的子字符串。- 或 -如果 startIndex 与此实例的长度相等且 length 为零,则为 Empty。
string value
);参数value
要查找的 String。 返回值如果找到该字符,则为 value 的索引位置;如果未找到该字符,则为 -1。如果 value 为 Empty,则返回值为 0。
http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/cpref/html/frlrfsystemstringmemberstopic.aspString.Substring 方法:
http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/cpref/html/frlrfsystemstringclasssubstringtopic.aspString.IndexOf 方法:
http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/cpref/html/frlrfsystemstringclassindexoftopic.asp