C#:如何用\替换\\

标签 c# string c#-4.0 escaping

我有这个字符串 temp,我想将 \\ 替换为 \

string temp = "\\h\\k";

我试过 temp.Replace("\\", "\") 但是输出是 hk 我希望输出为 \h\k

如何将"\\"替换为"\"

谢谢

最佳答案

temp.Replace("\\\\", "\\")

这应该有效。

关于C#:如何用\替换\\,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5658453/

相关文章:

c# 树/思维导图 GUI

python - Pandas:如何从每行的一个单词重建字符串

c - 将 printf() 作为参数传递

c++ - 如果字符串是不可变的,为什么下面的代码在 turbo c++ 上运行

ASP.NET + NUnit : Good unit testing strategy for HttpModule using . NET 4

c#-4.0 - 如何在 C# 中将 SQLiteDataReader 值转换为 float

wpf - wpf 应用程序中的多个 Storyboard

c# - 查询Elastic Search时如何添加条件表达式?

c# autoclose 窗口 sleep 但文本消失

c# - LinqToTwitter 看不到所有私有(private)列表