What is the equivalent to Java's string.getBytes() in C#?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/7089640/equivalent-of-getbytes-in-java-to-c-sharp">Equivalent of getBytes() in Java to C#</a>  </p>
</blockquote>



<p>In Java:</p>

<pre><code>String s="abcde"; 
byte bar[] = s.getBytes();
</code></pre>

<p>In C#:</p>

<pre><code>for (int i = 0; i &lt; s.Length; i++)
{
    bar[i] = Convert.ToByte(s.Substring(i, 1)); 
}
</code></pre>

<p>I worked Java example getBytes to convert C# code. But the above C# code does not work.</p>
