StringInfo.SubstringByTextElements Method

Definition

Retrieves a substring of text elements from the current StringInfo object.

Overloads

SubstringByTextElements(Int32)

Retrieves a substring of text elements from the current StringInfo object starting from a specified text element and continuing through the last text element.

SubstringByTextElements(Int32, Int32)

Retrieves a substring of text elements from the current StringInfo object starting from a specified text element and continuing through the specified number of text elements.

SubstringByTextElements(Int32)

Source:
StringInfo.cs
Source:
StringInfo.cs
Source:
StringInfo.cs

Retrieves a substring of text elements from the current StringInfo object starting from a specified text element and continuing through the last text element.

C#
public string SubstringByTextElements(int startingTextElement);

Parameters

startingTextElement
Int32

The zero-based index of a text element in this StringInfo object.

Returns

A substring of text elements in this StringInfo object, starting from the text element index specified by the startingTextElement parameter and continuing through the last text element in this object.

Exceptions

startingTextElement is less than zero.

-or-

The string that is the value of the current StringInfo object is the empty string ("").

Remarks

Consider a string that consists of five text elements, indexed from 0 through 4. If the startingTextElement parameter is 1, the SubstringByTextElements method returns a substring that consists of the text elements for which the indexes are 1, 2, 3, and 4.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

SubstringByTextElements(Int32, Int32)

Source:
StringInfo.cs
Source:
StringInfo.cs
Source:
StringInfo.cs

Retrieves a substring of text elements from the current StringInfo object starting from a specified text element and continuing through the specified number of text elements.

C#
public string SubstringByTextElements(int startingTextElement, int lengthInTextElements);

Parameters

startingTextElement
Int32

The zero-based index of a text element in this StringInfo object.

lengthInTextElements
Int32

The number of text elements to retrieve.

Returns

A substring of text elements in this StringInfo object. The substring consists of the number of text elements specified by the lengthInTextElements parameter and starts from the text element index specified by the startingTextElement parameter.

Exceptions

startingTextElement is less than zero.

-or-

startingTextElement is greater than or equal to the length of the string that is the value of the current StringInfo object.

-or-

lengthInTextElements is less than zero.

-or-

The string that is the value of the current StringInfo object is the empty string ("").

-or-

startingTextElement + lengthInTextElements specify an index that is greater than the number of text elements in this StringInfo object.

Remarks

Consider a string that consists of five text elements, indexed from 0 through 4. If the startingTextElement parameter is 1 and the lengthInTextElements parameter is 3, the SubstringByTextElements method returns a substring that consists of the text elements for which the indexes are 1, 2, and 3.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1