string s = "tytyt"; var firstIndex = s.IndexOf("tyt"); var result = firstIndex != s.LastIndexOf("tyt") && firstIndex != -1;