public static void Main()
string text = "My dog is a cute dog";
Console.WriteLine(text + "\t Length: " + text.Length);
Console.WriteLine("\nPlease Enter Substring To Seek: ");
string sub = Console.ReadLine();
char[] arr = new char[sub.Length];
sub.CopyTo(0, arr, 0, sub.Length);
int pos = text.IndexOf(sub);
pos = text.LastIndexOf(sub);
pos = text.IndexOfAny(arr);
report(pos, text.Substring(pos, 1));
pos = text.LastIndexOfAny(arr);
report(pos, text.Substring(pos, 1));
static void report(int pos, string sub)
Console.WriteLine("'" + sub + "' Found At " + pos);
Console.WriteLine("'" + sub + "' Not Found!");