Share via


String.Substring Method

Definition

Overloads

Substring(Int32)

Returns a string that is a substring of this string.

Substring(Int32, Int32)

Returns a string that is a substring of this string.

Substring(Int32)

Returns a string that is a substring of this string.

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

Parameters

beginIndex
Int32

the beginning index, inclusive.

Returns

the specified substring.

Attributes

Exceptions

if start or start > length().

Remarks

Returns a string that is a substring of this string. The substring begins with the character at the specified index and extends to the end of this string.

Examples: <blockquote>

"unhappy".substring(2) returns "happy"
            "Harbison".substring(3) returns "bison"
            "emptiness".substring(9) returns "" (an empty string)

</blockquote>

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

Substring(Int32, Int32)

Returns a string that is a substring of this string.

[Android.Runtime.Register("substring", "(II)Ljava/lang/String;", "")]
public string Substring (int beginIndex, int endIndex);
[<Android.Runtime.Register("substring", "(II)Ljava/lang/String;", "")>]
member this.Substring : int * int -> string

Parameters

beginIndex
Int32

the beginning index, inclusive.

endIndex
Int32

the ending index, exclusive.

Returns

the specified substring.

Attributes

Exceptions

if start , start > end or end > length().

Remarks

Returns a string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex.

Examples: <blockquote>

"hamburger".substring(4, 8) returns "urge"
            "smiles".substring(1, 5) returns "mile"

</blockquote>

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