Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I convert to hexadecimal using the following method:

C#
byte[] a = Encoding.Default.GetBytes(Code1.Text);
string code = BitConverter.ToString(a);


I get the value that I want, but what is the way to convert new value to String again?
Posted

use Encoding.Default.GetString method plus some linq
C#
byte[] data = Encoding.Default.GetBytes("sample text");
string code = BitConverter.ToString(data);

byte[] data2 = code.Split('-').Select(b => Convert.ToByte(b, 16)).ToArray();
string codeback = Encoding.Default.GetString(data2);


there are many other ways to try, please check below link
BitConverter.ToString() in reverse?[^]
 
Share this answer
 
v2
Comments
King Fisher 31-Mar-15 13:29pm    
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