|
|
hello, i have a string likt this
string str1="hello"; now i need a array holding each character's value in integer format or hex value format.
- i have tried using str1.tochararray ,but the problem is,i read a string of data from a remote location(using sockets),and whne i receive data it will be in string format and some values will be in non ascii format ,so how can i convert each cahracter into corresponding integer or hex value | ||||
Loading
AlanPosted May 5, 2008, 4:44 PM
Try:
string str1="hello";
short[] charValues = new short[str1.Length];
for(int i = 0; i < str1.Length; i++)
{
charValues[i] = (short)str1[i];
}
foreach (short s in charValues)
{
Console.Write("{0} ", s);
}
Console.WriteLine();
/* output
104 101 108 108 111
*/