在C#中如何URL编码和解码
需要使用的类:System.Web.HttpUtility
在这个类中可以使用UrlEncode()和UrlDecode()方法进行编码和解码!
例
解码:
string s = "%5B1%2C2%5D";
string result = System.Web.HttpUtility.UrlDecode(s);
此时result的值为"[1,2]"
编码:
string s = "[1,2]";
string result = System.Web.HttpUtility.UrlEncode(s);
此时result的值为"%5B%31%2C%32%5D"
需要使用的类:System.Web.HttpUtility