如何提取第一个查询字符串多个查询字符串 [英] how to extract 1st query string multiple querystring

查看:103
本文介绍了如何提取第一个查询字符串多个查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的查询字符串是:id = 571551&locationId = 22&pg = 1&ln = 1

我想只提取id = 571551,我的结果应该是:locationId = 22&pg = 1&ln = 1.how can i这样做

解决方案

  string  q =  @  id = 571551& locationId = 22& pg = 1& ln = 1; 

string q2 = q.Substring(q.IndexOf( &)+ 1 );


< blockquote>



这里你可以看到查询字符串有一个查询字符串分隔符& 使用分割功能根据 deliminator(&)分离参数,它会产生数组中的参数。那么你可以跳过数组中所需的参数并使用 stringbuilder 重新构建查询字符串。



谢谢

Sisir Patro


您可以轻松地使用querystring:

 Request.QueryString [  ID] 

并在需要时单独使用。


my querystring is: id=571551&locationId=22&pg=1&ln=1
and i want to extract only id=571551 and my result should be: locationId=22&pg=1&ln=1.how can i do this

解决方案

string q = @"id=571551&locationId=22&pg=1&ln=1";

string q2 = q.Substring(q.IndexOf("&") + 1);


Hi,

Here you can see the query string is having a querystring separator "&" Use the split function to separate the parameters based on the deliminator (&) and it will result you the parameters in an array. then you can skip the required parameters from the array and reform the querystring using stringbuilder.

Thanks
Sisir Patro


you can easily get you desire querystring use:

Request.QueryString["ID"] 

and use it where needed separately.


这篇关于如何提取第一个查询字符串多个查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆