The text field with the property MultiLine
set to true has an array Lines
from which it is easy to extract the required information
int maxLines = textBox1.Lines.Length;
if(maxLines > 0)
{
string lastLine = textBox1.Lines[maxLines-1];
string lastWord = lastLine.Split(' ').Last();
}
Here you need a little caution. If your text block still does not contain lines, you need to enter a check on the number of lines presented
source
share