I\'m trying to make a function that returns the index of the Nth occurrence of a given char in a string.
Here is my attempt:
private int IndexOfNth(s
Not tested but something like this should work:
private int IndexOfNth(string str, char c, int n) { int index = -1; while (n-- > 0) { index = str.IndexOf(c, index + 1); if (index == -1) break; } return index; }