Reputation: 259
my code -
txtPhoneWork.Text.Replace("-","");
txtPhoneWork.Text.Replace("_", "");
txtMobile.Text.Replace("-", "");
txtMobile.Text.Replace("_", "");
txtPhoneOther.Text.Replace("-", "");
txtPhoneOther.Text.Replace("_", "");
location.ContactWork = txtPhoneWork.Text.Trim();
location.ContactMobile = txtMobile.Text.Trim();
location.ContactOther = txtPhoneOther.Text.Trim();
but it is not replacing and is there any method so that both -
and _
can be replaced in single function.
Upvotes: 2
Views: 39805
Reputation: 1476
get the replaced string in some variable
you can try this to replace multiple characters in single function string value= System.Text.RegularExpressions.Regex.replace(value, @"[-_]", "");
Upvotes: 0
Reputation: 630379
.Replace()
returns the string with the replacement performed (it doesn't change the original string, they're immutable), so you need a format like this:
txtPhoneWork.Text = txtPhoneWork.Text.Replace("-","");
Upvotes: 15