語言

String.Substring 方法

定義

多載

名稱 Description
Substring(Int32)

回傳一個是該字串子串的子字串。

Substring(Int32, Int32)

回傳一個是該字串子串的子字串。

Substring(Int32)

回傳一個是該字串子串的子字串。

[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

參數

beginIndex
Int32

起始索引,包含。

傳回

指定的子字串。

屬性

例外狀況

start start > length()

備註

回傳一個是該字串子串的子字串。 子字串從指定索引的字元開始,延伸至該字串的末尾。

範例: <blockquote>

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

</區塊引用>

Java 文件 java.lang.String.substring(int)

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於

Substring(Int32, Int32)

回傳一個是該字串子串的子字串。

[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

參數

beginIndex
Int32

起始索引,包含。

endIndex
Int32

專屬的終結索引。

傳回

指定的子字串。

屬性

例外狀況

start start > endend > length()

備註

回傳一個是該字串子串的子字串。 子串從指定的 beginIndex 開始,延伸至索引 endIndex - 1的字元。 因此子串的長度為 endIndex-beginIndex

範例: <blockquote>

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

</區塊引用>

Java 文件 java.lang.String.substring(int, int)

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於