C# Windows -Get rid of strange symbols

c

Using Xml Deserilization I am getting value back from xml file and store the values to appropriate controls.

I have an array of email addresses.I am assigning it to textbox as follows.

textEmailAddress=string.Join("\n", emp.Emails);

( During serilization i split those addresses using : textEmailAddress.Text.Split(new[] { '\n', ',' }); )

The textBox "textEmailAddress" is getting filled up with email addresses with 'new line' symbols.

I applied

textEmailAddress.Text
  = textEmailAddress.Text.Replace(Environment.NewLine, string.Empty);

but i am unable to remove the entire newline characters.

Best Answer

Environment.NewLine depends on the environment. On Windows it is the string "\r\n" (carriage return, line feed). To match

textEmailAddress=string.Join("\n", emp.Emails); 

you will have to do

textEmailAddress.Replace("\n", " ");

instead of using Environment.NewLine.