title: String must be exactly one character long
body: <p>I have what I think is an easy problem. For some reason the following code generates the exception, "String must be exactly one character long".</p>
  
  <pre><code>int n = 0;
  foreach (char letter in charMsg)
  {
      // Get the integral value of the character.
      int value = Convert.ToInt32(letter);
      // Convert the decimal value to a hexadecimal value in string form.
      string hexOutput = String.Format("{0:X}", value);
      //Console.WriteLine("Hexadecimal value of {0} is {1}", letter, hexOutput);
      charMsg[n] = Convert.ToChar(hexOutput);
      n++;
  }
  </code></pre>
  
  <p>The exception occurs at the <code>charMsg[n] = Convert.ToChar(hexOutput);</code> line. Why does it happen? When I check the values of <code>CharMsg</code> it seems to contain all of them properly, yet still throws an error at me.</p>
  
  <p><strong>UPDATE:</strong> I've solved this problem, it was my mistake. Sorry for bothering you.</p>
  
  <p>OK, this was a really stupid mistake on my part. Point is, with my problem I'm not even supposed to do this as hex values clearly won't help me in any way.</p>
  
  <p>What I am trying to do it to encrypt a message in an image. I've already encrypted the length of said message in last digits on each color channel of first pixel. Now I'm trying to put the very message in there. I lookt here: <a href="http://en.wikipedia.org/wiki/ASCII" rel="nofollow">http://en.wikipedia.org/wiki/ASCII</a> and said to myself without thinking that usung hexes would be a good idea. Can't belive I thought that.</p>