将所有黑色斜杠替换为正斜杠 [英] Replace all blackslashes with forward slash
本文介绍了将所有黑色斜杠替换为正斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
替换所有出现的"的最佳方法是什么?与"/"在C#中的字符串中?
What is the best way to replace all occurrences of "" with "/" in a string in c#?
我尝试了以下选项,但均无济于事.
I've tried the following options but neither work.
- variable.Replace(","/");
- variable.Replace(@``'',@``/'');
推荐答案
您应指定替换结果:
var res = variable. Replace("\\", "/"); // you need "\\" because "\" is escape symbol.
或
var res = variable.Replace(@"\", "/");
这篇关于将所有黑色斜杠替换为正斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文