C# as below:
public static int StrStr(string str1, string str2)
{
int result = -1;
int i = 0;
int j = 0;
while (i <= str1.Length - str2.Length)
{
if (str1[i] == str2[j])
{
if (j == str2.Length - 1)
{
result = i - j;
break;
}
else
{
j++;
}
}
else
{
i -= j;
j = 0;
}
i++;
}
return result;
}