最简单的方法来解析"查询字符串"格式化数据 [英] Easiest way to parse "querystring" formatted data

查看:153
本文介绍了最简单的方法来解析"查询字符串"格式化数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过以​​下code:

With the following code:

string q = "userID=16555&gameID=60&score=4542.122&time=343114";

什么会pferably解析值,$ P $没有写我自己的解析器最简单的方法?我在寻找的东西具有相同的功能的Request.QueryString [游戏ID]

推荐答案

pretty容易...使用的 HttpUtility.ParseQueryString方法

Pretty easy... Use the HttpUtility.ParseQueryString method.

未经检验的,但这应该工作:

Untested, but this should work:

var qs = "userID=16555&gameID=60&score=4542.122&time=343114";
var parsed = HttpUtility.ParseQueryString(qs);
var userId = parsed["userID"]; 
//  ^^^^^^ Should be "16555".  Note this will be a string of course.

这篇关于最简单的方法来解析"查询字符串"格式化数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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