Click here to Skip to main content
15,867,453 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

Counting lines in a string

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
11 Jan 2012CPOL 7.9K   1
How about using the extension method: return s.Count(c => (c == '\n'));
How about using the extension method:
return s.Count(c => (c == '\n'));

License

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


Written By
Student
Wales Wales
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralYou do realise that that is Linq in disguise? :laugh: Index ... Pin
OriginalGriff10-Jan-12 8:37
mveOriginalGriff10-Jan-12 8:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.