how to convert string into integer in c#

B

Bob

Hi,
How can i convert each character of the following string to the
integer value's.
"Hello World"
 
Q

qglyirnyfgfo

Bob,

If you don’t mind me asking. What is the purpose of you converting
these values to ints?

The reason why I ask is because you have to remember that the values
that you are converting are Unicode (UTF-16) values. There may be
times when you hit surrogate pair values and a simple conversion to
int won’t do what you expect.

If you are dealing with ASCII rage values then you should be fine.

It’s been a while since the last time I messed around with this
Unicode stuff so someone correct me if I am wrong!

Thaks
Rene.
 
B

Bob

Bob,

If you don’t mind me asking. What is the purpose of you converting
these values to ints?

The reason why I ask is because you have to remember that the values
that you are converting are Unicode (UTF-16) values. There may be
times when you hit surrogate pair values and a simple conversion to
int won’t do what you expect.

If you are dealing with ASCII rage values then you should be fine.

It’s been a while since the last time I messed around with this
Unicode stuff so someone correct me if I am wrong!

Thaks
Rene.

Rene,
I am a student. And these are my first steps. Just trying to walk. It
is part of a question. Now i have to figure out how to discard the
space and add the integer values.
But i think there are some things i should do on my own.
I understand what Marc explained. I saw on the internet and in books
that there is an option to do the same with Parse. But i did not
understand that.
Thanks
Bob
 
J

jake

Bob,
(int)'1' ----> returns the ascii value of the character '1', which is
49
int.Parse("1") -----> returns the integer value of "1", which is 1
Hope this helps.
jake
 
B

Bob

Bob,
(int)'1' ----> returns the ascii value of the character '1', which is
49
int.Parse("1") -----> returns the integer value of "1", which is 1
Hope this helps.
jake

Thanks Jack. It is much clearer like this.
Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top