title: What does C# do when typecasting a letter to an int?
body: <p>We've to implement an encryption for an external interface. The owner of the interface has given documentation of how to preform the same encryption on our side. However, this documentation is in C# and we work in PHP.</p>
  
  <p>Most of the parts we understand except for where they seem to typecast a hash to an int. Their code reads:</p>
  
  <pre><code>// hashString exists and is a md5 a like string
  int[] keyBuffer = new int[hashString.length];
  for (int i=0; i&lt;hashString.length; i++) {
      keyBuffer[i] = (int)hashString[i];
  }
  </code></pre>
  
  <p>In PHP, when casting a letter as int, you get 0 (int). As we can't imagine this is what the third party means, we believe C# does something else.</p>
  
  <p><strong>Does C# also cast to int 0, or possibly to a char?</strong></p>
  
  <p>Second, the original hashString is 320 long. This means the code will be creating an int which is 320 long?? In PHP you don't have this idea of reserving memory as C# does here. But when we try to typecast a 320 long string to an int we get an int which is 19 'chars' long.</p>
  
  <p><strong>Does C# also create a shorter int when typecasting a really long 'number' in a string?</strong></p>