string str = "Hello World"; int index = str.IndexOf('W'); Console.WriteLine(index); // Output: 6
string str = "The quick brown fox jumps over the lazy dog"; int index = str.IndexOf("lazy"); Console.WriteLine(index); // Output: 32This method is part of the core C# language and is included in the System namespace, so no additional package or library is required.