NAnt SDK Documentation - v0.92

StringFunctions.IndexOf Method 

Returns the position of the first occurrence in the specified string of the given search string.

[Visual Basic]
<Function(Name:="index-of")>
Public Shared Function IndexOf( _
   ByVal source As String, _
   ByVal value As String _
) As Integer
[C#]
[Function(Name="index-of")]
public static int IndexOf(
   string source,
   string value
);

Parameters

source
The string to search.
value
The string to locate within source.

Return Value

The lowest-index position of value in source if it is found, or -1 if source does not contain value.

If value is an empty string, the return value will always be 0.

Remarks

This function performs a case-sensitive word search using the invariant culture.

Example

string::index-of('testing string', 'test') ==> 0
string::index-of('testing string', '') ==> 0
string::index-of('testing string', 'Test') ==> -1
string::index-of('testing string', 'ing') ==> 4

See Also

StringFunctions Class | NAnt.Core.Functions Namespace