我的代码 -
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();
Run Code Online (Sandbox Code Playgroud)
但它不更换和是否有任何这样既方法-和_可在单一的功能来代替.
Nic*_*ver 15
.Replace() 返回执行替换的字符串(它不会更改原始字符串,它们是不可变的),因此您需要这样的格式:
txtPhoneWork.Text = txtPhoneWork.Text.Replace("-","");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
30709 次 |
| 最近记录: |