如何在C#中对URL进行解码操作

avatar
作者
筋斗云
阅读量:0

在C#中进行URL解码操作可以使用System.Web.HttpUtility类的UrlDecode方法。示例如下:

using System; using System.Web;  class Program {     static void Main()     {         string url = "https://www.example.com/search?q=%E6%90%9C%E7%B4%A2";         string decodedUrl = HttpUtility.UrlDecode(url);                  Console.WriteLine(decodedUrl);     } } 

在上面的示例中,我们首先创建一个URL字符串,然后使用UrlDecode方法对其进行解码操作,最后输出解码后的URL。在这个例子中,输出结果将是"https://www.example.com/search?q=搜索"。

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!