dipk11
Junior Member level 2
Hi all,
I have a byte array byte[] dStream = new byte[6];
the contents are as follows
{0x7C 0x00 0x7A 0x10 0x00 0x00}
When I check the array values in watch window, I can see them converted into decimal and not hex.
I want to generate a String Data= "7c,00,7a,10,00,00"
How can I do this in my c#? Kindly help
- - - Updated - - -
Hi, I wrote the following code. but I am getting the string in decimal. How do I get each value in hex?
output:
"124,0,122,16,0,0,4,0,0,2,123,48"
I want it to be "7C,00,7A,10,00,00,04,00,00,02,7B,30"
Kindly tell me the changes in the present code...
- - - Updated - - -
Hey I did it like this.
But these have too many lines of codes...But works perfectly. And gives me 24bit data.
I have a byte array byte[] dStream = new byte[6];
the contents are as follows
{0x7C 0x00 0x7A 0x10 0x00 0x00}
When I check the array values in watch window, I can see them converted into decimal and not hex.
I want to generate a String Data= "7c,00,7a,10,00,00"
How can I do this in my c#? Kindly help
- - - Updated - - -
Hi, I wrote the following code. but I am getting the string in decimal. How do I get each value in hex?
Code C# - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 String cArgument = ""; for (int j = 0; j < 12; j++) { if (j == 11) { cArgument = cArgument + dStream[j]; } else { cArgument = cArgument + dStream[j] + ","; } }
output:
"124,0,122,16,0,0,4,0,0,2,123,48"
I want it to be "7C,00,7A,10,00,00,04,00,00,02,7B,30"
Kindly tell me the changes in the present code...
- - - Updated - - -
Hey I did it like this.
Code C# - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 //converting to hex value string[] datastring = new string[dStream.Length]; for (int i = 0; i < dStream.Length; i++) { datastring[i] = dStream[i].ToString("X"); } String cArgument = ""; for (int j = 0; j < 24; j++) { if (j == 23) { cArgument = cArgument + datastring[j]; } else { cArgument = cArgument + datastring[j] + ","; } }
But these have too many lines of codes...But works perfectly. And gives me 24bit data.
Last edited by a moderator: