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?
SamuPosted Aug 29, 2007, 6:05 AM
Many thanks ;)
AlanPosted Aug 29, 2007, 5:38 AM
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);