You need to use
Split
to split the text box text and then have a loop though each line - i.e. each address.
The following assumes that you have put a carriage-return-linefeed between each address (i.e. have hit the Enter button between them)
var x = txtto.Text.Split(Environment.NewLine[0]);
foreach (var s in x)
Console.WriteLine("|{0}|", s.Trim());
Note the use of
[0]
at the end of
NewLine
- this is because I need to split on a
char
not a string. This also explains the
.Trim()
used when I'm displaying the results ... NewLine is CarriageReturn + LineFeed.
Also note the use of
Environment.NewLine
instead of hard-coding ascii values for CRLF
Edit - a slightly neater solution
var x = textBox1.Text.Split(new [] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
foreach (var s in x)
Console.WriteLine("|{0}|", s);