string.replace("""," \"")在c#中给出错误 [英] string.replace(""","\"") giving error in c#

查看:109
本文介绍了string.replace("""," \"")在c#中给出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

方法替换没有重载需要1个参数

no overload for method replace takes 1 arguments

推荐答案

你必须将两个字符或两个字符串传递给替换方法。目前你只传递一个字符串(由于转义规则,逗号嵌入在字符串中)。
You must pass either two characters or two strings to the Replace method. Currently you''re passing just one string (the comma is embedded in the string, due to the escaping rules).


我不确定你想要替换哪两个字符串,但可能你想要这样的东西:

I''m not sure exactly what two strings you want to replace, but probably you want something like this:
myString.replace("\"", "\\\"");

用反斜杠替换双引号的所有单个实例双引号。

Which replaces all the single instances of double quote with a backslash and a double quote.


string newString = "its valid";
 newString = newString.Replace(" ", "_");





查看此链接



string.replace [ ^ ]


这篇关于string.replace("""," \"")在c#中给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆