Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read the last line in a textbox?

I have a multiline textbox that constantly gets updated. I need to read only the last word/sentence in the textbox.

string lastLine = textBox1.ReadLine.Last();
like image 448
user3002030 Avatar asked Oct 03 '15 15:10

user3002030


1 Answers

Try this:

if (textBox1.Lines.Any())
{
    string lastLine = textBox1.Lines[textBox1.Lines.Length - 1];
}

And for last word:

string lastword = lastLine.Split(' ').Last();
like image 59
Salah Akbari Avatar answered Oct 11 '22 17:10

Salah Akbari