NAnt SDK Documentation - v0.85-nightly-2005-11-09

StringFunctions.Substring Method 

[This is preliminary documentation and subject to change.]

Returns a substring of the specified string.

[Visual Basic]
<Function(Name:="substring")>
Public Shared Function Substring( _
   ByVal str As String, _
   ByVal startIndex As Integer, _
   ByVal length As Integer _
) As String
[C#]
[Function(Name="substring")]
public static string Substring(
   string str,
   int startIndex,
   int length
);

Parameters

str
input string
startIndex
position of the start of the substring
length
the length of the substring

Return Value

If the length is greater than zero, the function returns a substring starting at character position startIndex with a length of length characters.

If the length is equal to zero, the function returns an empty string.

Remarks

Missing <remarks> documentation for M:NAnt.Core.Functions.StringFunctions.Substring(System.String,System.Int32,System.Int32)

Exceptions

Exception Type Condition
ArgumentOutOfRangeException startIndex or length is less than zero.
ArgumentOutOfRangeException startIndex is greater than the length of str.
ArgumentOutOfRangeException startIndex plus length indicates a position not within str.

Example

string::substring('testing string', 0, 4) ==> 'test'
string::substring('testing string', 8, 3) ==> 'str'
string::substring('testing string', 8, 0) ==> ''
string::substring('testing string', -1, 5) ==> ERROR
string::substring('testing string', 8, -1) ==> ERROR
string::substring('testing string', 5, 17) ==> ERROR

See Also

StringFunctions Class | NAnt.Core.Functions Namespace