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();
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();
You can extract the last line from any string as follows:
To get the last line of a TextBox you can use:
A textbox with the
MultiLine
property set to true has an array ofLines
from which it is easy to extract the info requiredA bit of caution here is needed. If your textBox still doesn't contain any lines you need to introduce a check on the number of lines present
Try this:
And for last word: