public static void Main()
Console.WriteLine(GetIndex())
public static int GetIndex (string str, char value, int startIndex, int count)
throw new ArgumentNullException(nameof(str), "str cannot be null");
if (string.IsNullOrEmpty(str))
int endIndex = count + startIndex;
if (endIndex >= str.Length)
if (startIndex < str.Length && str[startIndex] == value)
if (str[startIndex] == value)
if (startIndex <= endIndex)
return GetIndex(str, value, startIndex + 1, count - 1);