Adding 2 Zeros after each byte in textbox
-
ok i really hounestly (on my own mind and heart) cant think of ANY code to start this, right so a value in a textbox say equals "999" i want to then convert it to hex (i know how to do that with SB) then having it add 1 byte (00) after each byte so : "3900390039" how would i go about doing this ? Thanks
-
ok i really hounestly (on my own mind and heart) cant think of ANY code to start this, right so a value in a textbox say equals "999" i want to then convert it to hex (i know how to do that with SB) then having it add 1 byte (00) after each byte so : "3900390039" how would i go about doing this ? Thanks
Is this an attempt at UTF-16? Why not iterate over the 999, converting one character at a time and adding the '00'?
Regards, Rob Philpott.
-
ok i really hounestly (on my own mind and heart) cant think of ANY code to start this, right so a value in a textbox say equals "999" i want to then convert it to hex (i know how to do that with SB) then having it add 1 byte (00) after each byte so : "3900390039" how would i go about doing this ? Thanks
-
ok i really hounestly (on my own mind and heart) cant think of ANY code to start this, right so a value in a textbox say equals "999" i want to then convert it to hex (i know how to do that with SB) then having it add 1 byte (00) after each byte so : "3900390039" how would i go about doing this ? Thanks
OK.., I giving u a idea about this.., read text box value to a byte array...,
byte[] mybyte = Encoding.UTF8.GetBytes(textbox1.Text);
declaring 0x00 byte
byte x = 0x00;
declare a new byte array and add, bytes as per your requirement. Tnanks
Rajesh B --> A Poor Workman Blames His Tools <--
-
Try this:
string s1 = "999";
byte[] b1 = new byte[s1.Length * 2];
int index = 0;
foreach (char ch in s1)
{
b1[index++] = (byte)ch;
b1[index++] = 0;
}txtspeak is the realm of 9 year old children, not developers. Christian Graus
:thumbsup::thumbsup::thumbsup:
Rajesh B --> A Poor Workman Blames His Tools <--
-
OK.., I giving u a idea about this.., read text box value to a byte array...,
byte[] mybyte = Encoding.UTF8.GetBytes(textbox1.Text);
declaring 0x00 byte
byte x = 0x00;
declare a new byte array and add, bytes as per your requirement. Tnanks
Rajesh B --> A Poor Workman Blames His Tools <--