我需要在一个类库程序集中对URL进行编码,但不想引用System.Web。该URL包含多个空格。
https://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.quote where symbol in ("YHOO","AAPL")&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=
当我使用System.Net.WebUtility.UrlEncode()方法时,空格会被替换为"+",但这种方式不起作用。我需要将它们替换为"%20"。
如何在不引用System.Web的情况下实现这一点?