I want to find the position of a substring in a string if present without using any string method including indexof. I tried so much times but failed. Will anybody tell me h
string mainString = Console.ReadLine(); string subString = Console.ReadLine(); for (int i = 0; i <= mainString.Length - subString.Length; i++) { bool match = true; for (int j = 0; j < subString.Length && mainString[i + j] != subString[j]; j++) { match = false; } if (match) Console.WriteLine(i); }