{"id":188,"date":"2016-03-02T13:00:07","date_gmt":"2016-03-02T13:00:07","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=188"},"modified":"2022-02-17T06:24:14","modified_gmt":"2022-02-17T06:24:14","slug":"byte-array-strings","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/c-sharp\/strings\/byte-array-strings","title":{"rendered":"Byte Array Strings"},"content":{"rendered":"<h4>\n\tString Direct To Byte Array<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\tString sTemp;\r\n\tByte[] TxData;\r\n\r\n\tsTemp = &quot;Hello&quot;;\r\n\tTxData = System.Text.Encoding.UTF8.GetBytes(sTemp);\r\n\r\n<\/code><\/pre>\n<h4>\n\tByte Array To String<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\tSystem.Diagnostics.Debug.WriteLine(&quot;CommsByteArray: &quot; + Encoding.UTF8.GetString(CommsByteArray));\r\n<\/code><\/pre>\n<p>\n\t&nbsp;\n<\/p>\n<pre>\r\n<code>\r\n\tstring sTemp = Encoding.ASCII.GetString(new byte[]{ 41 });\r\n<\/code><\/pre>\n<h4>\n\tRemove Nulls From The String<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\tsTemp = sTemp.Replace(&quot;\\0&quot;, &quot;&quot;);\r\n<\/code><\/pre>\n<p>\n\t&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>String Direct To Byte Array String sTemp; Byte[] TxData; sTemp = &quot;Hello&quot;; TxData = System.Text.Encoding.UTF8.GetBytes(sTemp); Byte Array To String System.Diagnostics.Debug.WriteLine(&quot;CommsByteArray: &quot; + Encoding.UTF8.GetString(CommsByteArray)); &nbsp; string sTemp = Encoding.ASCII.GetString(new byte[]{ 41 }); Remove Nulls From The String sTemp = sTemp.Replace(&quot;\\0&quot;, &quot;&quot;); &nbsp;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-188","post","type-post","status-publish","format-standard","hentry","category-strings"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=188"}],"version-history":[{"count":4,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/188\/revisions"}],"predecessor-version":[{"id":343,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/188\/revisions\/343"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}