Click here to Skip to main content
Click here to Skip to main content

Counting lines in a string

By , 11 Jan 2012
 
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)

About the Author

George Swan
Student
Wales Wales
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralYou do realise that that is Linq in disguise? :laugh: Index ... PinmvpOriginalGriff10-Jan-12 8:37 

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

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

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130617.1 | Last Updated 11 Jan 2012
Article Copyright 2012 by George Swan
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid