- public static int NthIndexOf(this string s, char c, int n)
- {
- var takeCount = s.TakeWhile(x => (n -= (x == c ? 1 : 0)) > 0).Count();
- return takeCount == s.Length ? -1 : takeCount;
- }
Untitled
Posted by Anonymous on Fri 7th Oct 2011 14:44
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.