Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Counting lines in a string

, 11 Jan 2012
Rate this:
Please Sign up or sign in to vote.
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)

About the Author

George Swan
Student
Wales Wales
No Biography provided

Comments and Discussions

 
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.

| Advertise | Privacy | Mobile
Web02 | 2.8.140718.1 | Last Updated 11 Jan 2012
Article Copyright 2012 by George Swan
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid