R
Russell Mangel
// Need help converting String to Byte[]
// How do I get this String in a Byte Array
String strBytes = "FFD9FFD8";
// Like this...
Byte[] Bytes = {0xFF, 0xD9, 0xFF, 0xD8};
// This is no good, as it converts each character to hex
System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();
Byte[] bytes = ascii.GetBytes(strBytes);
// This is no good
foreach (Byte b in bytes)
{
Console.Write("{0:X2} ", b);
}
Console.WriteLine("\n");
// This is what I want
foreach(Byte bb in Bytes)
{
Console.Write("{0:X2} ", bb);
}
// Can Someone Help?
// How do I get this String in a Byte Array
String strBytes = "FFD9FFD8";
// Like this...
Byte[] Bytes = {0xFF, 0xD9, 0xFF, 0xD8};
// This is no good, as it converts each character to hex
System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();
Byte[] bytes = ascii.GetBytes(strBytes);
// This is no good
foreach (Byte b in bytes)
{
Console.Write("{0:X2} ", b);
}
Console.WriteLine("\n");
// This is what I want
foreach(Byte bb in Bytes)
{
Console.Write("{0:X2} ", bb);
}
// Can Someone Help?