string class : SubString(int,int) method

Description

Gets a new instance of the string that taken out the specified number of characters from the specified position.

Syntax

stringInstance.SubString(int startPosition, int number)

Arguments

ClassNameDescription
intstartPositionStarting position of the search.
intnumberA number of characters that is removed.

Return value

ClassDescription
stringA new instance of the string that taken out the specified number of characters from the specified position.

Sample code

//anyString is a instance of string type.

string subString = anyString.SubString(5, 5);

Notes

It's a wrapper of the System.Globalization.StringInfo.SubstringByTextElements(Int32,Int32).

The index is zero-based.

Links for reference

Copyright © Rice All rights reserved.