String.IndexOf Method (Char)

Reports the index of the first occurrence of the specified Unicode character in this string.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

'Declaration
Public Function IndexOf ( _
	value As Char _
) As Integer
'Usage
Dim instance As String
Dim value As Char
Dim returnValue As Integer

returnValue = instance.IndexOf(value)
public int IndexOf (
	char value
)
public function IndexOf (
	value : char
) : int

Parameters

value

A Unicode character to seek.

Return Value

The index position of value if that character is found, or -1 if it is not.

Index numbering starts from zero.

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 their Unicode scalar values are the same. To perform a culture-sensitive search, use the CompareInfo.IndexOf method, where a Unicode scalar 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.

The following code example demonstrates how you can search a String for a character using the IndexOf method.

No code example is currently available or this language may not be supported.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Show: