다음을 통해 공유


AbstractStringBuilder.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(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", "GetIndexOf_Ljava_lang_String_IHandler")]
public virtual int IndexOf (string? str, int fromIndex);
[<Android.Runtime.Register("indexOf", "(Ljava/lang/String;I)I", "GetIndexOf_Ljava_lang_String_IHandler")>]
abstract member IndexOf : string * int -> int
override this.IndexOf : string * int -> int

Parameters

str
String

the substring to search for.

fromIndex
Int32

the index from which to start the search.

Returns

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

Attributes

Remarks

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

The returned index is the smallest value k for which:

{@code
                k >= Math.min(fromIndex, this.length()) &&
                              this.toString().startsWith(str, k)
            }

If no such value of k exists, then -1 is returned.

Java documentation for java.lang.AbstractStringBuilder.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(String)

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

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

Parameters

str
String

the substring to search for.

Returns

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

Attributes

Remarks

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

The returned index is the smallest value k for which:

{@code
            this.toString().startsWith(str, k)
            }

If no such value of k exists, then -1 is returned.

Java documentation for java.lang.AbstractStringBuilder.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