title: Getting upper and lower byte of an integer in C# and putting it as a char array to send to a com port, how?
body: <p>In C I would do this</p>
  <blockquote>
  <p>int number = 3510;</p>
  <p>char upper = number &gt;&gt; 8;</p>
  <p>char lower = number &amp;&amp; 8;</p>
  <p>SendByte(upper);</p>
  <p>SendByte(lower);</p>
  </blockquote>
  <p>Where upper and lower would both = 54</p>
  <p>In C# I am doing this:</p>
  <blockquote>
  <pre><code>            int number = Convert.ToInt16(&quot;3510&quot;);
              byte upper = byte(number &gt;&gt; 8);
              byte lower = byte(number &amp; 8);
              char upperc = Convert.ToChar(upper);
              char lowerc = Convert.ToChar(lower);
              data = &quot;GETDM&quot; + upperc + lowerc;
              comport.Write(data);
  </code></pre>
  </blockquote>
  <p>However in the debugger number = 3510, upper = 13 and lower = 0
  this makes no sense, if I change the code to &gt;&gt; 6 upper = 54 which is absolutely strange.</p>
  <p>Basically I just want to get the upper and lower byte from the 16 bit number, and send it out the com port after &quot;GETDM&quot;</p>
  <p>How can I do this? It is so simple in C, but in C# I am completely stumped.</p>