indexOf() in C# code example
Example 1: c sharp index of substring
// To find the index of the first substring in a string use
// 'IndexOf()'
string str = "Hello World!"
str.IndexOf("o"); // Output: 4
// You can give a starting index and a length to search at
str.IndexOf("o", 6, 4); // Output: 7
// To find the last instance of a substring use 'LastIndexOf()'
str.LastIndexOf("o"); // Output: 7
Example 2: c# IndexOf
string word = "Hello";
int where = word.IndexOf("e");
// int where returns index number where the letter "e" is located.
// --0-1-2-3-4-- < Index number
// --H-e-l-l-o-- < Word
// In this case, the letter "e" is located in the index number 1
Example 3: strinng.indexOf c#
int index = String.IndexOf(char x);
int index = String.IndexOf(string x);