{"id":655,"date":"2016-11-24T11:09:54","date_gmt":"2016-11-24T11:09:54","guid":{"rendered":"https:\/\/ibex.tech\/windows-iot\/?p=180"},"modified":"2022-09-13T14:58:40","modified_gmt":"2022-09-13T13:58:40","slug":"and-or-and-binary-operations-on-variables-2","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/memory-uwp-programming-in-c\/and-or-and-binary-operations-on-variables-2","title":{"rendered":"AND, OR and binary operations on variables"},"content":{"rendered":"<p><span style=\"color:#FF8C00\"><em><strong>C# is not the same as C or C++!!!!! &nbsp;Simple byte operations for example do not result in a byte result, they often result in an Int32 result<\/strong><\/em><\/span><\/p>\n<h4>\n\tAn example binary operation<\/h4>\n<p>This will generat the error &#8220;Cannot implicitly convert type &#8216;int&#8217; to &#8216;byte&#8217;. An explicit conversion exists (are you missing a cast)&#8221;:<\/p>\n<pre><code>\n\tTxData[ByteIndex++] = (byte)TagIdCharacter[0] | 0x80;\t\n<\/code><\/pre>\n<p>Its because the result of the IOR operation does not result in a byte, so you need to&nbsp;use&nbsp;parenthesis:<\/p>\n<pre><code>\n\tTxData[ByteIndex++] = (byte)(TagIdCharacter[0] | 0x80);\t\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>C# is not the same as C or C++!!!!! &nbsp;Simple byte operations for example do not result in a byte result, they often result in an Int32 result An example binary operation This will generat the error &#8220;Cannot implicitly convert type &#8216;int&#8217; to &#8216;byte&#8217;. An explicit conversion exists (are you missing a cast)&#8221;: TxData[ByteIndex++] = [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[129],"tags":[],"class_list":["post-655","post","type-post","status-publish","format-standard","hentry","category-memory-uwp-programming-in-c"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/655","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=655"}],"version-history":[{"count":1,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/655\/revisions"}],"predecessor-version":[{"id":1167,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/655\/revisions\/1167"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}