StringInfo.SubstringByTextElements 方法

定義

從目前的 StringInfo 物件擷取文字項目的子字串。

多載

SubstringByTextElements(Int32)

在目前的 StringInfo 物件中擷取文字項目的子字串,範圍從指定的文字項目開始,一直持續到最後一個文字項目。

SubstringByTextElements(Int32, Int32)

在目前 StringInfo 物件中擷取文字項目的子字串,範圍從指定的文字項目開始,一直持續到指定的文字項目數目。

SubstringByTextElements(Int32)

在目前的 StringInfo 物件中擷取文字項目的子字串,範圍從指定的文字項目開始,一直持續到最後一個文字項目。

public:
 System::String ^ SubstringByTextElements(int startingTextElement);
public string SubstringByTextElements (int startingTextElement);
member this.SubstringByTextElements : int -> string
Public Function SubstringByTextElements (startingTextElement As Integer) As String

參數

startingTextElement
Int32

StringInfo 物件中文字項目之以零為起始的索引。

傳回

String

這個 StringInfo 物件中的文字項目的子字串,範圍從 startingTextElement 參數指定的文字項目索引開始,一直持續到這個物件中的最後一個文字項目。

例外狀況

startingTextElement 小於零。

-或- 做為目前 StringInfo 物件值的字串是空字串 ("")。

備註

請考慮由五個文字元素組成的字串,索引是從0到4。 如果 startingTextElement 參數為1,則方法會傳回 SubstringByTextElements 子字串,其中包含索引為1、2、3和4的文字元素。

適用於

SubstringByTextElements(Int32, Int32)

在目前 StringInfo 物件中擷取文字項目的子字串,範圍從指定的文字項目開始,一直持續到指定的文字項目數目。

public:
 System::String ^ SubstringByTextElements(int startingTextElement, int lengthInTextElements);
public string SubstringByTextElements (int startingTextElement, int lengthInTextElements);
member this.SubstringByTextElements : int * int -> string
Public Function SubstringByTextElements (startingTextElement As Integer, lengthInTextElements As Integer) As String

參數

startingTextElement
Int32

StringInfo 物件中文字項目之以零為起始的索引。

lengthInTextElements
Int32

要擷取的文字項目數目。

傳回

String

這個 StringInfo 物件中的文字項目的子字串。 子字串由 lengthInTextElements 參數所指定的文字項目數目所組成,而且從 startingTextElement 參數所指定的文字項目索引開始。

例外狀況

startingTextElement 小於零。

-或- startingTextElement 大於或等於字串的長度,這個字串就是目前 StringInfo 物件的值。

-或- lengthInTextElements 小於零。

-或- 做為目前 StringInfo 物件值的字串是空字串 ("")。

-或- startingTextElement + lengthInTextElements 指定一個索引,其大於這個 StringInfo 物件中的文字項目數目。

備註

請考慮由五個文字元素組成的字串,索引是從0到4。 如果 startingTextElement 參數為1,且 lengthInTextElements 參數為3,則方法會傳回 SubstringByTextElements 子字串,其中包含索引為1、2和3的文字元素。

適用於