Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个字符串/Images/Me.jpg,我想用这样的反斜杠替换正斜杠,我正在\Images\Me.jpg使用 string.Replace("/","\"); 但输出是\\Images\\Me.jpg请帮忙
/Images/Me.jpg
\Images\Me.jpg
\\Images\\Me.jpg
你需要避开斜线
string.Replace("/", "\\") string.Replace("/", @"\")
Visual Studios intellisense 仍然会显示“\\”,如果你将鼠标悬停在字符串上,你会发现一个放大镜,点击它。这将显示真正的字符串
尝试转义反斜杠,
string.Replace("/","\\");