【问题标题】:Remove backslash from string c#从字符串 c# 中删除反斜杠
【发布时间】:2016-11-29 13:50:54
【问题描述】:

我正在尝试以编程方式为查询参数添加一个值以报告服务。

 List<QueryParameter> lst = new List<QueryParameter>();
 QueryParameter qp = new QueryParameter();
 qp.Name = "@UserID";
 qp.Value = "[@UserID]";
 lst.Add(qp);

值被插入,但带有\ 字符,是因为@。我的 QueryParameter 值应该类似于 [@UserID],而是显示为 \[@UserID\]。

如何从值中删除\,并且在调试时\ 不显示。

非常感谢任何建议。

更新1:

【问题讨论】:

  • 插入的值在哪里,在哪里显示为\[@UserID\]?
  • @TimSchmelter - 更新了我的帖子。当我打开我的 rdl 并检查参数时,值会显示为图片中提到的那样。
  • @RahulHendawe - qp.value 是 QueryParameter,它没有拆分方法。
  • 是的,试试这个:string requestPath = qp.Value;string[] requestPathParts = requestPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
  • @RahulHendawe - 我仍然能够看到 `. Is it getting created internally somewhere or because of @? But I'm sure it's because of [@` 组合。

标签: c# asp.net .net reporting-services


【解决方案1】:

如果我正确理解您的问题:

testString = testString.Replace(@"\","");

【讨论】:

  • 斜线不在字符串本身中,它们仅在 UI 中。这段代码不会有任何影响
猜你喜欢
  • 2021-09-14
  • 2015-03-28
  • 2011-10-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多