I have a field that I use to hold text. I am going to hold the text in a HTML textarea but I need to set the number of lines.
How can I count the number of line feeds in a string so I can set the textarea rows?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A line break is one or two characters, depending on the system. On a windows system it’s the two character combination
\r\n, but you can look for only one of them when counting them.As a string is enumerable, you can use the
Countextension method: