I have the following function that checks a string and stores only letters and numbers. All other characters are deleted.
However, I want one character only "-" to exit this function and not be deleted. For example, I want Jean-Paul to remain with a “-” between the two names. How can i do this?
String NameTextboxString = NameTextbox.Text;
NameTextboxString = new string((from c in NameTextboxString
where char.IsLetterOrDigit(c)
select c).ToArray);
nameLabel.Text = NameTextboxString;
source
share