簡體   English   中英

如何在C#中查找字符串中的雙引號

[英]How to find double quotes in string in C#

如果一個字符串有雙引號,

string str = "it is a "text""

我該怎么知道字符串是否有“。

如何刪除雙引號?

檢查它是否包含引號: str.Contains("\\"");

刪除引號: str.Replace("\\"","");

 string str = "it is a \"text\"";
 string str_without_quotes = str.Replace("\"", "");

不要費心檢查它是否包含引號,只需替換它們。

刪除str = str.Replace("\\"", String.Empty);

別忘了好老(char)34! 它也可以用來代替“\\”“和”“”“”“!

bool containsQuote = str.Contains("\"");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM