using (WebClient client = new WebClient()) { byte[] response = client.UploadValues("http://dork.com/service", new NamevalueCollection() {{ "home", "Cosby" },{ "favorite+flavor", "flies" } }); string result = System.Text.Encoding.UTF8.GetString(response); }您将需要这些包括:
using System;using System.Collections.Specialized;using System.Net;
如果您坚持使用静态方法/类:
public static class Http{ public static byte[] Post(string uri, NamevalueCollection pairs) { byte[] response = null; using (WebClient client = new WebClient()) { response = client.UploadValues(uri, pairs); } return response; }}然后简单地:
var response = Http.Post("http://dork.com/service", new NamevalueCollection() { { "home", "Cosby" }, { "favorite+flavor", "flies" }});


