StringFunctions.NthIndexOf

Extension method to find the index of the Nth occurrence of a character in a string.

public static int NthIndexOf(string s,
	char c,
	int n)

Return Value

The index of the Nth occurrence if found or -1 if not.

Parameters

s
The string to search.

c
The character to find.

n
The occurrence to find.

Remarks

Taken from Wayne Maurer's solution at http://stackoverflow.com/questions/2571716/find-nth-occurrence-of-a-character-in-a-string


See also:

Class StringFunctions