using System;
using System.Web;
class Program
{
static void Main()
{
// 原始编码后的URL字符串
string encodedUrl = "https%3A%2F%2Fwww.example.com%2Fpath%3Fquery%3Dvalue%26another%3D123";
// 使用 HttpUtility.UrlDecode 方法解码URL
string decodedUrl = HttpUtility.UrlDecode(encodedUrl);
// 输出解码后的URL
Console.WriteLine("Decoded URL: " + decodedUrl);
}
}
% 加上两位十六进制数表示。HttpUtility.UrlDecode 方法后,返回解码后的原始 URL 字符串。如果你在项目中使用的是 .NET Core 或 .NET 5+,请确保你已经添加了对 System.Web 的引用。如果使用的是 .NET Core 或更高版本,可以使用 WebUtility.UrlDecode 作为替代。
下一篇:c#控件
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站