pastebin - collaborative debugging tool RSS

Posted by Anonymous on Fri 7th Oct 2011 14:44
raw | new post

  1. public static int NthIndexOf(this string s, char c, int n)
  2. {
  3.     var takeCount = s.TakeWhile(x => (n -= (x == c ? 1 : 0)) > 0).Count();
  4.     return takeCount == s.Length ? -1 : takeCount;
  5. }

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}

All content is user-submitted.
The administrators of this site ( are not responsible for their content.
Abuse reports should be emailed to us at