I have a multiline textbox, which the user would type something into and press a button. The button does something with the text, depending on which characters are used. But i can't work out how to recognise a newline in the textbox. I thought i could do this:
Code:
if (tbxIn.Text[i] == Convert.ToChar(Environment.NewLine))
{
// action here...
}
As a little more explanation, Environment.NewLine is two character string containing a carriage return character ('\r') and a line feed character ('\n'). If you convert that to a char then you simply drop the line feed and get the carriage return. You haven't really specified what you're trying to do but you may be interested to know that both the TextBox and RichTextBox have a Lines property, which returns a string array of the Text split on the line breaks.