How can I do to convert a byte[] array into a char[] array or a string avoiding loops for each byte?
Thank you!
Printable View
How can I do to convert a byte[] array into a char[] array or a string avoiding loops for each byte?
Thank you!
I'm not sure but try Convert.ToCharArr();
Yessss, if that would exist...Quote:
I'm not sure but try Convert.ToCharArr();
But... what's the aim of your replay?
Ok bro, I dont know about the char[], but if you want to convert a byte[] to string, you can try this Convert.ToBase64String().
BTW the aim of my reply was to try and help you.:mad: Calm down and go have a cup of coffee man.
copied from MSDN byte conversion topic:
Code:ASCIIEncoding AE = new ASCIIEncoding();
byte[] ByteArray = { 69, 110, 99, 111, 100, 105, 110, 103, 32, 83, 116, 114, 105, 110, 103, 46 };
char[] CharArray = AE.GetChars(ByteArray);
for(int x = 0;x <= CharArray.Length - 1; x++)
{
Console.Write(CharArray[x]);
}
take a look at System.Text.Encoding.ASCII -- if memory serves you can probaby GetChars() too.Code:private byte[] StrToBytes(string s)
{
return System.Text.Encoding.ASCII.GetBytes(s);
}