如何动态删除字符串中的逗号 [英] How to remove comma from string dynamically
本文介绍了如何动态删除字符串中的逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
UPDATE tbl SET Colname= '6277',Colname= '8/16/2017 2:39:17 PM',Where mrddmonth_review_id =448
想先删除逗号
我尝试过:
Want to remove comma first where
What I have tried:
UPDATE tbl SET Colname= '6277',Colname= '8/16/2017 2:39:17 PM',Where mrddmonth_review_id =448
推荐答案
sqlStatement = sqlStatement.Replace(",Where", " Where");
只需将,WHERE替换为WHERE即可。非常简单。
Just replace ",WHERE" with " WHERE". Pretty simple.
如果您的字符串变量首先包含(','),一个简单的解决方案是用空char替换逗号(','):
One simple solutions would be to replace the comma (',') with empty char if your string variable contains the (',') in the first place:
string sqlStatement = "<pre>UPDATE tbl SET Colname= '6277',Colname= '8/16/2017 2:39:17 PM',Where mrddmonth_review_id =448";
if (sqlStatement.Contains(',')) {
sqlStatement = sqlStatement.Replace(',', ' ');
}
另一个解决方案是使用
Another solution would be to use the
sqlStatement.Remove()
字符串变量自己提供的方法......
method that string variables provide by themselves...
这篇关于如何动态删除字符串中的逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文