I have a textBox control that lets the user their email address/addresses.
The use may enter email by supplying comma or in next line (new line).
The task is to check whether the textBox contains new line (\n) character or
commas then split the email addresses accordingly.
I applied:
string[] emails = txtemailAddress.Text.Split(‘\n’);
it splits the email addresses.
I need a single routine that should check whether the textBox contains “,’ {or} ‘\n’ and
split the string based on the split character.If the email address is invalid in format it should throw exception as well.
Thanks in advance.
The string.Split method accepts an array of characters to split on:
Regarding validating email addresses, this is one of those tasks that may seem simple at first glance, but that proves to be more of a challange than expected. This has been dicussed here at SO before.