{"id":2054,"date":"2023-04-01T21:20:09","date_gmt":"2023-04-01T13:20:09","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=2054"},"modified":"2023-04-07T06:05:42","modified_gmt":"2023-04-06T22:05:42","slug":"basic-technical-points-of-csharp","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/04\/01\/basic-technical-points-of-csharp\/","title":{"rendered":"CSharp \u57fa\u672c\u6280\u672f\u70b9"},"content":{"rendered":"<h2>C# \u5c06string\u8f6c\u6362\u6210int\u578b<\/h2>\n<p><!-- more --><\/p>\n<pre><code class=\"language-csharp\">int intA = 0;\nintA = int.Parse(str);\nint.TryParse(str, out intA);\nintA = Convert.ToInt32(str);<\/code><\/pre>\n<h2>C# \u5b57\u7b26\u4e32\u6bd4\u8f83\u65b9\u6cd5<\/h2>\n<pre><code class=\"language-csharp\">string.Compare(x, y);\nstring.Equals(x, y);<\/code><\/pre>\n<h2>C# \u7f16\u7801\u8f6c\u6362<\/h2>\n<pre><code class=\"language-csharp\">byte[] unicodeBytes = Encoding.Unicode.GetBytes(&quot;Hello\uff0c\u4f60\u597d\uff01&quot;);\nConsole.WriteLine(&quot;Unicode\u957f\u5ea6: {0}&quot;, unicodeBytes.Length);\nbyte[] defaultBytes = Encoding.Convert(Encoding.Unicode, Encoding.Default, unicodeBytes);\nConsole.WriteLine(&quot;Default\u957f\u5ea6: {0}&quot;, defaultBytes.Length);\nmSerialPort.WriteLine(Encoding.Default.GetString(defaultBytes));<\/code><\/pre>\n<h2>C# \u5b57\u7b26\u4e32string\u4e0ebyte[]\u6570\u7ec4\u4e92\u8f6c<\/h2>\n<pre><code class=\"language-csharp\">\/\/String To Byte[]\nbyte[] byteArray = System.Text.Encoding.Default.GetBytes(str);\n\n\/\/Byte[] To String\nstring str = System.Text.Encoding.Default.GetString(byteArray);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>C# \u5c06string\u8f6c\u6362\u6210int\u578b int intA = 0; intA = int.Parse(str);  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[518],"tags":[],"class_list":["post-2054","post","type-post","status-publish","format-standard","hentry","category-csharp"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2054"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2054\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}