使用字符串的 Replace 方法,将 / 替换成 // 即可:

string str = "c:/program files/"; string newStr = str.Replace("/", "//");

Console.WriteLine(newStr); // 输出 "c://program files//"

注意:在 C# 中,/ 是路径分隔符,而 \ 是转义字符,因此如果要将 / 替换成 \,需要使用双反斜杠表示转义字符:newStr = str.Replace("/", "\\");

c# 怎么把字符串中的 替换成

原文地址: http://www.cveoy.top/t/topic/htH8 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录