using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; namespace ConsoleApplication4 { class Program { static void Main(string[] args) { CreateHttpRequestMessage(); } public static HttpRequestMessage CreateHttpRequestMessage() { HttpRequestMessage requestMessage = new HttpRequestMessage(); JsonHSBCMailMessage JsonHsbcMailMessage = new JsonHSBCMailMessage { Host = "host111", Port = 1231312312 }; string Body = JsonConvert.SerializeObject(JsonHsbcMailMessage); requestMessage.Content = new StringContent(Body, Encoding.UTF8, "application/x-www-form-urlencoded"); return requestMessage; } } class JsonHSBCMailMessage { public string Host { get; set; } public int Port { get; set; } } }
* Newtonsoft.Json 需要自己下载并加载到引用列表
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。