How many rows string has
Hello, my problem is that i have varchars in my database and some of those contains multiple rows, now when im printing them, text collides. If i could somehow find out how many rows my string has, this would be no problem. Is there anyway to find it out? or is there any other better way to do this?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

AlanRank #669 · 3.6K reputationPosted Aug 29, 2007, 1:38 AM EDT
If you know which newline character(s) your database uses, then you can find out how many rows there are with code like this:
char newLine = '\n'; //say
string myString = "The\nquick\nbrown\nfox\njumped\nover\nthe\nlazy\ndog";
int numOfRows = myString.Split(newLine).Length; // 9
Moreover, you can get the actual content of each row from:
string[] rows = myString.Split(newLine);
Samu3 reputationPosted Aug 29, 2007, 2:05 AM EDT
Many thanks ;)