c# 泛型demo

private void Fn_Post<T>(T dto, string api)
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("http://localhost:51529/");
            string json = DefaultJsonSerializer.Serialize(dto);
            HttpContent httpcontent = new StringContent(json);
            httpcontent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var result = client.PostAsync(api, httpcontent).Result;
            client.Dispose();
        }

 

posted @ 2019-08-18 16:39  jasonlai2016  阅读(207)  评论(0编辑  收藏  举报