Get the position of substring of a string.
string s = "endmemo csharp tutorial"; int p = s.IndexOf('n'); //1 int p2 = s.IndexOf(' '); //7, 1st occurrence int p3 = s.IndexOf('me'); //3 int p4 = s.IndexOf('med'); //-1, not exist //get the 2nd occurrence of letter e int p = s.IndexOf('e'); int p2 = s.Length; if (p < s.Length) p2 = s.IndexOf('e', p+1); //4
string s = "Endmemo csharp tutorial"; int p = s.IndexOf("e",System.StringComparison.OrdinalIgnoreCase); //0
using System.Collections.Generic; List<string> lst = new List<string>(); lst.Add("Monday"); lst.Add("Tuesday"); lst.Add("Wednesday"); int p = lst.IndexOf("Tuesday"); //1
using System.Collections; ArrayList al = new ArrayList(); al.Add("Monday"); al.Add("Tuesday"); al.Add("Wednesday"); int num = al.IndexOf("Tuesday"); //1