Вот моя попытка:
Код: Выделить всё
private int IndexOfNth(string str, char c, int n)
{
int index = str.IndexOf(c) + 1;
if (index >= 0)
{
string temp = str.Substring(index, str.Length - index);
for (int j = 1; j < n; j++)
{
index = temp.IndexOf(c) + 1;
if (index < 0)
{
return -1;
}
temp = temp.Substring(index, temp.Length - index);
}
index = index + (str.Length);
}
return index;
}
Также в качестве побочного вопроса: если я хочу, чтобы символ был символом табуляции, мне передать эту функцию '\t' или что?
Подробнее здесь: https://stackoverflow.com/questions/113 ... n-a-string
Мобильная версия