METHOD

String.IndexOf (String, StringComparison)

Finds the first occurrence of a substring with the chosen comparison, returning its UTF-16 index or -1. Use ordinal comparison for exact protocol tokens.

Formal Syntax & Structure

csharp syntaxcsharp
text.IndexOf(value, StringComparison.Ordinal)

Working Example

Example Snippetcsharp
using System;Console.WriteLine("bin:AB".IndexOf("AB", StringComparison.Ordinal)); // 4
C# & .NET Reference