public int CountNewLines(string nl, string text) { int i = -1; int c = -1; do { c++; i++; i = text.IndexOf(nl, i); } while (i != -1); return c; }