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();
Try this:
if (textBox1.Lines.Any())
{
string lastLine = textBox1.Lines[textBox1.Lines.Length - 1];
}
And for last word:
string lastword = lastLine.Split(' ').Last();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With