asp.net.ph

String.Substring Method

System Namespace   String Class


Retrieves a substring from this instance.

Overload List

1. Retrieves a substring from this instance. The substring starts at a specified character position.

2. Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length.


Example

[ VB ]
Dim myString As String = "abc"
Dim test1 As Boolean = String.Compare ( myString.Substring ( 2, 1 ), "c" ) = 0 ' This is true.
myString.Substring ( 3, 1 ) ' This throws ArgumentOutOfRangeException.
Dim test2 As Boolean = String.Compare ( myString.Substring ( 3, 0 ), String.Empty ) = 0 ' This is true.

[ C# ]
String myString = "abc";
bool test1 = String.Compare ( myString.Substring ( 2, 1 ), "c" ) == 0; // This is true.
myString.Substring ( 3, 1 ); // This throws ArgumentOutOfRangeException.
bool test2 = String.Compare ( myString.Substring ( 3, 0 ), String.Empty ) == 0; // This is true.

[ C++ ]

String *myString = L"abc";
bool test1 = String::Compare ( myString->Substring ( 2,1 ), L"c" ) == 0;  // This is true.
myString->Substring ( 3,1 );  // This throws ArgumentOutOfRangeException.
bool test2 = String::Compare ( myString->Substring ( 3,0 ), String::Empty ) == 0;  // This is true.

[ JScript ]
var myString : String = "abc";
var test1 : boolean = String.Compare ( myString.Substring ( 2, 1 ), "c" ) == 0; // This is true.
myString.Substring ( 3, 1 );  // This throws ArgumentOutOfRangeException.
var test2 : boolean = String.Compare ( myString.Substring ( 3, 0 ), String.Empty ) == 0; // This is true.
See Also

String Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph