報告指定 Unicode 字符在此字符串中的第一個匹配項的索引。其原型為:
public int IndexOf(char value)
參數value為要查找的 Unicode 字符。
返回值:如果找到該字符,則為 value 的從零開始的索引位置;如果未找到,則為 -1。
如:
string str = "武林網VEVB。";
int iPos = str.IndexOf('I');
其返回值為:3
同時,IndexOf方法還有其它8種重載形式:
(1)public int IndexOf(string value)
(2)public int IndexOf(char value, int startIndex)
(3)public int IndexOf( string value, int startIndex)
(4)public int IndexOf(string value,StringComparison comparisonType )
(5)public int IndexOf(char value, int startIndex,int count )
(6)public int IndexOf(string value,int startIndex,int count )
(7)public int IndexOf(string value,int startIndex,StringComparison comparisonType )
(8)public int IndexOf(string value,int startIndex,int count, StringComparison comparisonType )
新聞熱點
疑難解答