{"id":4047,"date":"2020-12-10T13:30:05","date_gmt":"2020-12-10T04:30:05","guid":{"rendered":"https:\/\/okamurax.com\/?p=4047"},"modified":"2020-12-10T13:30:05","modified_gmt":"2020-12-10T04:30:05","slug":"c-byte%e9%85%8d%e5%88%97%e3%82%9216%e9%80%b2%e6%95%b0%e6%96%87%e5%ad%97%e5%88%97%e3%81%b8","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=4047","title":{"rendered":"C# Byte\u914d\u5217\u309216\u9032\u6570\u6587\u5b57\u5217\u3078"},"content":{"rendered":"<pre class=\"lang:c# decode:true \">        static public string ModelListToHexString(List&lt;IEstimateModel&gt; modelList)\r\n        {\r\n            using (var memoryStream = new MemoryStream())\r\n            {\r\n                var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();\r\n                formatter.Serialize(memoryStream, modelList);\r\n                return BitConverter.ToString(memoryStream.ToArray()).Replace(\"-\", \"\");\r\n            }\r\n        }\r\n\r\n\r\n        \/\/ 16\u9032\u6570\u6587\u5b57\u5217\uff1e\u30d0\u30a4\u30c8\u914d\u5217\uff1e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30ea\u30b9\u30c8\r\n        static public List&lt;IEstimateModel&gt; HexStringToModelList(string hexString)\r\n        {\r\n            List&lt;byte&gt; byteList = new List&lt;byte&gt;();\r\n\r\n            for (int i = 0; i &lt; hexString.Length; i += 2)\r\n            {\r\n                byteList.Add(byte.Parse(hexString.Substring(i, 2),System.Globalization.NumberStyles.AllowHexSpecifier));\r\n            }\r\n\r\n            using (var memoryStream = new MemoryStream(byteList.ToArray()))\r\n            {\r\n                memoryStream.Seek(0, SeekOrigin.Begin);\r\n                var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();\r\n\r\n                try\r\n                {\r\n                    return (List&lt;IEstimateModel&gt;)formatter.Deserialize(memoryStream);\r\n                }\r\n                catch\r\n                {\r\n                    return new List&lt;IEstimateModel&gt;();\r\n                }\r\n                \r\n            }\r\n        }<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>static public string ModelListToHexString(List&lt;IEstimateModel&gt; modelList) { using (var memoryStream = ne &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=4047\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# Byte\u914d\u5217\u309216\u9032\u6570\u6587\u5b57\u5217\u3078&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9],"class_list":["post-4047","post","type-post","status-publish","format-standard","hentry","category-1","tag-c-net"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/4047","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4047"}],"version-history":[{"count":1,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/4047\/revisions"}],"predecessor-version":[{"id":4048,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/4047\/revisions\/4048"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4047"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}