<(E-Mail Removed)> wrote:
> If we pass in '9' the above function should return 9, but it doesnt. It
> returns 57, which is the unicode representation of the character 9.
What makes you think it should return 9?
> However if we use Convert.Int32(string), and pass in "9", it returns 9.
>
> Any ideas why?
Because they both act as documented. From Convert.ToInt32(char):
<quote>
Converts the value of the specified Unicode character to the equivalent
32-bit signed integer.
</quote>
From Convert.ToInt32(string):
<quote>
Converts the specified String representation of a number to an
equivalent 32-bit signed integer.
</quote>
Note the difference between the string (i.e. textual) *representation*
of a number and an actual *value*. (Any char is in itself a 16 bit
unsigned value.)
--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too