StringSegment.IndexOf 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
IndexOf(Char, Int32, Int32) |
取得此 StringSegment 中第一次出現 |
IndexOf(Char) |
取得此 StringSegment 中第一次出現 |
IndexOf(Char, Int32) |
取得此 StringSegment 中第一次出現 |
IndexOf(Char, Int32, Int32)
取得此 StringSegment 中第一次出現 c
字元位置的以零起始索引。
搜尋會從 start
開始,並檢查指定數目的 count
字元位置。
public:
int IndexOf(char c, int start, int count);
public int IndexOf (char c, int start, int count);
member this.IndexOf : char * int * int -> int
Public Function IndexOf (c As Char, start As Integer, count As Integer) As Integer
參數
- c
- Char
要搜尋的 Unicode 字元。
- start
- Int32
開始搜尋的以零起始索引位置。
- count
- Int32
要檢查的字元數。
傳回
若找到該字元,則為從 StringSegment 開頭開始 c
的以零起始索引位置;若沒找到,則為 -1。
例外狀況
start
或 count
小於零,或 start
+ count
大於 Length。
適用於
IndexOf(Char)
取得此 StringSegment 中第一次出現 c
字元位置的以零起始索引。
public:
int IndexOf(char c);
public int IndexOf (char c);
member this.IndexOf : char -> int
Public Function IndexOf (c As Char) As Integer
參數
- c
- Char
要搜尋的 Unicode 字元。
傳回
若找到該字元,則為從 StringSegment 開頭開始 c
的以零起始索引位置;若沒找到,則為 -1。
適用於
IndexOf(Char, Int32)
取得此 StringSegment 中第一次出現 c
字元位置的以零起始索引。
搜尋會在 start
開始。
public:
int IndexOf(char c, int start);
public int IndexOf (char c, int start);
member this.IndexOf : char * int -> int
Public Function IndexOf (c As Char, start As Integer) As Integer
參數
- c
- Char
要搜尋的 Unicode 字元。
- start
- Int32
開始搜尋的以零起始索引位置。
傳回
若找到該字元,則為從 StringSegment 開頭開始 c
的以零起始索引位置;若沒找到,則為 -1。
例外狀況
start
大於或等於 Length 或小於零。