c#中html链接字符串连接的正确声明是什么

时间:2017-06-15 07:18:42

标签: c# string

我在C#(Winforms)中有一个从REST API获取数据的项目。我声明字符串错了。由于空格

,我在引用引号时遇到问题

我特别在这里遇到问题:Under % 20Investigation % 2C % 20Pending"%2C%20"In % 20Progress"%2C%20Reopened%2C%20"On % 20Hold

string url = "http://jira.ncr.com/rest/api/latest/search?jql=project%20in%20(project%2C%20project%2C%20project%2C%20project%2C%20project)%20AND%20status%20in%20("Under%20Investigation%2C%20Pending"%2C%20"In%20Progress"%2C%20Reopened%2C%20"On%20Hold")&startAt=0&maxResults=100&fields=key,summary,labels";

2 个答案:

答案 0 :(得分:1)

您可以像

一样转义字符串
"http://jira.ncr.com/rest/api/latest/search?jql=project%20in%20(project%2C%20project%2C%20project%2C%20project%2C%20project)%20AND%20status%20in%20(\"Under%20Investigation%2C%20Pending\"%2C%20\"In%20Progress\"%2C%20Reopened%2C%20\"On%20Hold\")&startAt=0&maxResults=100&fields=key,summary,labels"

使用Encode可能是更好的解决方案,我猜......

为此案件工作 https://msdn.microsoft.com/en-us/library/zttxte6w(v=vs.110).aspx

答案 1 :(得分:0)

尝试在字符串url的开头添加“@”,字符串中通常被解释为转义序列的任何内容都将被忽略。