Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Counting lines in a string

5.00/5 (7 votes)
9 Jan 2012CPOL 12.1K  
Can't we have something as below?int n=(s.Split(new char[]{'n'})).Length;where n is the number of lines?

Can't we have something as below?


C#
int n=(s.Split(new char[]{'\n'})).Length;

where n is the number of lines?

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)