Hi,
How can i convert each character of the following string to the
integer value's.
"Hello World" 6 1795
foreach (char c in "Hello World")
{
Console.WriteLine((int)c);
}
Marc
On Jun 5, 12:23 pm, Marc Gravell <marc.grav...@gmail.comwrote:
foreach (char c in "Hello World")
{
Console.WriteLine((int)c);
}
Marc
Didn't know, it was that simple.
Thanks, it worked.
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.
On Jun 5, 6:52*am, Bob <t2ch...@yahoo.comwrote:
On Jun 5, 12:23 pm, Marc Gravell <marc.grav...@gmail.comwrote:
* * * * *foreach (char c in "Hello World")
* * * * *{
* * * * * * *Console.WriteLine((int)c);
* * * * *}
Marc
Didn't know, it was that simple.
Thanks, it worked.
On Jun 5, 3:16 pm, qglyirnyf...@mailinator.com wrote:
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.
On Jun 5, 6:52 am, Bob <t2ch...@yahoo.comwrote:
On Jun 5, 12:23 pm, Marc Gravell <marc.grav...@gmail.comwrote:
foreach (char c in "Hello World")
{
Console.WriteLine((int)c);
}
Marc
Didn't know, it was that simple.
Thanks, it worked.
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
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
On Jun 5, 10:28 am, Bob <t2ch...@yahoo.comwrote:
On Jun 5, 3:16 pm, qglyirnyf...@mailinator.com wrote:
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.
On Jun 5, 6:52 am, Bob <t2ch...@yahoo.comwrote:
On Jun 5, 12:23 pm, Marc Gravell <marc.grav...@gmail.comwrote:
foreach (char c in "Hello World")
{
Console.WriteLine((int)c);
}
Marc
Didn't know, it was that simple.
Thanks, it worked.
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
On Jun 6, 9:26 pm, jake <jakedim...@gmail.comwrote:
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
On Jun 5, 10:28 am, Bob <t2ch...@yahoo.comwrote:
On Jun 5, 3:16 pm, qglyirnyf...@mailinator.com wrote:
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.
On Jun 5, 6:52 am, Bob <t2ch...@yahoo.comwrote:
On Jun 5, 12:23 pm, Marc Gravell <marc.grav...@gmail.comwrote:
foreach (char c in "Hello World")
{
Console.WriteLine((int)c);
}
Marc
Didn't know, it was that simple.
Thanks, it worked.
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
Thanks Jack. It is much clearer like this.
Bob This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: IamZadok |
last post by:
Hi
I was wondering if anyone knew how to convert a string or an integer
into a Static Char.
Thx
|
by: Convert TextBox.Text to Int32 Problem |
last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
|
by: Carlos |
last post by:
I have a strinf with comma separated field. Is is possible to convert it to
a Structure ?
Thanks
|
by: MrKrich |
last post by:
I want to convert Hexadecimal or normal integer to Binary. Does VB.Net has function to do that? I only found Hex function that convert normal integer to Hexadecimal.
|
by: Mika M |
last post by:
Hi!
I've made little code to convert string into hex string...
Public ReadOnly Property ToHexString(ByVal text As String) As String
Get
Dim arrBytes As Integer() = CharsToBytes(text)
Dim sb...
|
by: Drew |
last post by:
Hi All:
I know I am missing something easy but I can't find the problem! I
have a program which reads an integer as input.
The output of the program should be the sum of all the digits in the...
|
by: Niyazi |
last post by:
Hi all,
I have a integer number from 1 to 37000. And I want to create a report in
excel
that shows in 4 alphanumeric length.
Example:
I can write the cutomerID from 1 to 9999 as:
1 ---->...
|
by: priyanka |
last post by:
Hi there,
I want to convert a String into integer.
I get the string from a file using :
string argNum;
getline(inputStream,argNum);
I now need to convert argNum into integer.
|
by: elliotng.ee |
last post by:
I have a text file that contains a header 32-bit binary. For example,
the text file could be:
%%This is the input text
%%test.txt
Date: Tue Dec 26 14:03:35 2006...
|
by: shellon |
last post by:
Hi all:
I want to convert the float number to sortable integer, like the
function float2rawInt() in java, but I don't know the internal
expression of float, appreciate your help!
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |