在运行时将//替换为/

编程入门 行业动态 更新时间:2024-10-27 18:25:49
本文介绍了在运行时将//替换为/的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在//我想要单/的路径中.每当我调试它时,我都会在运行时获取//.我也用过替换方法.但它不起作用.我的代码是

i'm getting // in path i want single /. whenever i'm debugging it i'm getting // at run time. i have also used replace method. but it isn't working. My code is

string inputFile = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\InputFiles\\" + config.country + ".txt"; inputFile = inputFile.Replace(@"\\", @"\");

推荐答案

仅在调试模式下会得到 \\ ,因为在可视化字符串文字时,调试器会为该字符串重新转义.可视化的目的,但是,当使用它进行操作时,字符串文字将只包含一个 \ .

You're getting \\ only in debug mode, because when visualizing the string literal the debugger is re-escaping it for the visualization purposes, however when operating with it, the string literal will contain only a single \.

更多推荐

在运行时将//替换为/

本文发布于:2023-11-12 07:52:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580928.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时将

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!