我在字符串中有Json文件(例如):
@{
"Url": "http://site.com/?q=windows8"
}
如何在c#(Windows 8)上?q=
之后获取信息。抱歉我的英文。
答案 0 :(得分:2)
您可以使用查询字符串。
Code Behind文件中的
public String q
{
get
{
if (Request.QueryString["q"] == null)
return String.Empty;
return Convert.ToString(Request.QueryString["q"]);
}
}
然后使用下面的行获取值
var index = ('<%=q%>');
答案 1 :(得分:1)
你可以这样做:
string s =“myURL /?q = windows8”;
// Loop through all instances of ?q=
int i = 0;
while ((i = s.IndexOf("?q=", i)) != -1)
{
// Print out the substring. Here : windows8
Console.WriteLine(s.Substring(i));
// Increment the index.
i++;
}