asp.net.ph

String.IndexOf Method ( Char, Int32 )

System Namespace   String Class


Reports the index of the first occurrence of a given Unicode character in the given String. The search starts at a specified character position.

[ VB ]
<Serializable>
Overloads Public Function IndexOf ( _
   ByVal value As Char, _
   ByVal startIndex As Integer _
) As Integer

[ C# ]
[ Serializable ]
public int IndexOf (
   char value,
   int startIndex
);

[ C++ ]
[ Serializable ]
public: int IndexOf (
   __wchar_t value,
   int startIndex
);

[ JScript ]
public Serializable
function IndexOf (
   value : Char,
   startIndex : int
) : int;

Parameters

value
A Unicode character to seek.
startIndex
The search starting position.

Return Value

A positive 32-bit signed integer, the index, indicating the character position in the given String where value was found; otherwise, -1 if value was not found.

Exceptions


Exception Type Condition
ArgumentOutOfRangeException startIndex is less than zero or specifies a position beyond the end of this instance.

Remarks

Index numbering starts from zero.

The search ranges from startIndex to the end of the string.

The search for value is case-sensitive.

This method performs an ordinal ( culture-insensitive ) search, where a character is considered equivalent to another character only if the Unicode values are the same. To perform a culture-sensitive search, use the CompareInfo.IndexOf method, where a Unicode value representing a precomposed character, such as the ligature 'Æ' ( U+00C6 ), might be considered equivalent to any occurrence of the character's components in the correct sequence, such as "AE" ( U+0041, U+0045 ), depending on the culture.

See Also

String Members   String.IndexOf Overload List   Int32   Char   IndexOfAny   LastIndexOf   LastIndexOfAny 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