Why char. Parse(string) returns a number?

Asked

Viewed 74 times

3

I am making a program that uses Typecast, but when I converted a string to char (char.Parse()), received the following return: 115's'

What is the reason for the conversion of string to char return a number in front?

Saída da conversão

1 answer

5


The method char.Parse() exists basically to convert a character of a string on a die of the kind char as simply as possible.

This method returns the character that exists within the string. That one string can not have more than one character, otherwise it gives error. So if you have a "A", will now have a 'A'. Note the delimiters I used, it’s the same character but of different types. It’s like having a number 1 with short, or how int or how long, all are number 1 but the data types are different.

The function does not return 115, returns only the s even, Visual Studio is showing you an equivalent auxiliary number of this character, in this case it is an ASCII or Unicode code. This data is just to help, what matters is the character s, it may be that its context has some use to know the number, but it is less common.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.