Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a byte value of 0 that I need to convert to 00. The following is still showing 0:

string temp = struct_App.value.ToString();  //struct value is a byte and equals 0
string.Format("{0:X02}", temp);
Posted

1 solution

Put the formatting into the .ToString call like this...

C#
string temp = struct_App.value.ToString("X02");  //struct value is a byte and equals 0
 
Share this answer
 
Comments
RaisKazi 20-Apr-12 21:23pm    
Simple short and correct. My 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900