Forums - C# Corner

Forum guidelines
Rajavel G

Rajavel G

  • 1.4k
  • 51
  • 3.1k

C# code to count number of lines in textbox ?

Jul 6 2017 7:16 AM
C# code to count number of lines in text box ?
 
 string strtext = textbox1.text;
strtext = strtext.Replace('\r', '\n').Trim();
rslt = 0;
foreach (string s in strtext.Split('\n'))
rslt++;
txtline.Text = rslt.ToString();
 
 
I tried that above.. but wrap lines of text box is not included with in count??
Thanks in Advance
 

Answers (4)