String.IndexOf Method

Definition

Overloads

IndexOf(String, Int32)

Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.

IndexOf(Int32, Int32)

Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.

IndexOf(Int32)

Returns the index within this string of the first occurrence of the specified character.

IndexOf(String)

Returns the index within this string of the first occurrence of the specified substring.

IndexOf(String, Int32)

Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.

[Android.Runtime.Register("indexOf", "(Ljava/lang/String;I)I", "")]
public int IndexOf (string str, int fromIndex);
[<Android.Runtime.Register("indexOf", "(Ljava/lang/String;I)I", "")>]
member this.IndexOf : string * int -> int

Parameters

str
String

the substring to search for.

fromIndex
Int32

the index from which to start the search.

Returns

Int32

the index of the first occurrence of the specified substring, starting at the specified index, or -1 if there is no such occurrence.

Attributes

Exceptions

if subString is null.

Remarks

Java documentation for java.lang.String.indexOf(java.lang.String, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

IndexOf(Int32, Int32)

Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.

[Android.Runtime.Register("indexOf", "(II)I", "")]
public int IndexOf (int ch, int fromIndex);
[<Android.Runtime.Register("indexOf", "(II)I", "")>]
member this.IndexOf : int * int -> int

Parameters

ch
Int32

a character (Unicode code point).

fromIndex
Int32

the index to start the search from.

Returns

Int32

the index of the first occurrence of the character in the character sequence represented by this object that is greater than or equal to fromIndex, or -1 if the character does not occur.

Attributes

Remarks

Java documentation for java.lang.String.indexOf(int, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

IndexOf(Int32)

Returns the index within this string of the first occurrence of the specified character.

[Android.Runtime.Register("indexOf", "(I)I", "")]
public int IndexOf (int ch);
[<Android.Runtime.Register("indexOf", "(I)I", "")>]
member this.IndexOf : int -> int

Parameters

ch
Int32

a character (Unicode code point).

Returns

Int32

the index of the first occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur.

Attributes

Remarks

Java documentation for java.lang.String.indexOf(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

IndexOf(String)

Returns the index within this string of the first occurrence of the specified substring.

[Android.Runtime.Register("indexOf", "(Ljava/lang/String;)I", "")]
public int IndexOf (string str);
[<Android.Runtime.Register("indexOf", "(Ljava/lang/String;)I", "")>]
member this.IndexOf : string -> int

Parameters

str
String

the substring to search for.

Returns

Int32

the index of the first occurrence of the specified substring, or -1 if there is no such occurrence.

Attributes

Exceptions

if string is null.

Remarks

Java documentation for java.lang.String.indexOf(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to