public static void Main()
var result = StrStr("my name is christian", "name");
Console.WriteLine("result: " + result);
public static int StrStr(string haystack, string needle) {
if (needle == null || needle == "")
if (haystack == null || needle == "")
if (needle.Length > haystack.Length)
for (int i=0; i<=haystack.Length - needle.Length; i++)
if (haystack[i] == needle[0])
Console.WriteLine(string.Format("i: {0}, j: {1}", i, haystack[i]));
for (int j=1; j <needle.Length; j++)
if (haystack[i+j]!=needle[j])
Console.WriteLine(string.Format("isSame: {0}", isSame));