简体   繁体   English

在C#中替换字符“

[英]Replace character " in C#

I'd like to replace the character " by a space in a string in C#. But I have an issue when writing the function : 我想用C#中的字符串空格替换字符。但是在编写函数时我遇到了一个问题:

myString.Replace("""," ")

The first argument seems to be an issue. 第一个论点似乎是一个问题。 Any idea 任何的想法

逃避它:

myString.Replace("\""," ")

使用接受字符而不是字符串的重载

myString.Replace('"', ' ');

You need to escape the character by putting \\ before it: 你需要通过在它之前放置\\来逃避角色:

myString=myString.Replace("\""," ");

or user this: 或用户:

 myString=myString.Replace('"',' ');

Escape it. 逃避它。

You can use regular strings: 您可以使用常规字符串:

myString.Replace("\""," ")

or verbatim strings : 逐字 字符串

myString.Replace(@""""," ")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM