title: Globally defining a function in C#
body: <p>I have two functions which I seem to be including in software quite a lot to convert strings and byte arrays between types. The usage is something like this:</p>
  
  <pre><code>string str = "Hello world";
  byte[] b = strToByteArray(str);
  </code></pre>
  
  <p>Firstly, is there a way I can include this in the System namespace so I don't have to define it in code anymore?</p>
  
  <p>Secondly, is there a way to define it as part of the string class, so the usage would be more like:</p>
  
  <pre><code>string str = "Hello world";
  byte[] b = str.ToByteArray();
  </code></pre>