c# hex string to byte array code example
Example 1: c# string to byte array
string author = "Mahesh Chand";
byte[] bytes = Encoding.ASCII.GetBytes(author);
string str = Encoding.ASCII.GetString(bytes);
Example 2: byte array to hex c#
public static string ByteArrayToString(byte[] ba)
{
return BitConverter.ToString(ba).Replace("-","");
}
Example 3: c# string to byte array
string someText = "some data as text.";
byte[] bytes = Encoding.ASCII.GetBytes(author);
string str = Encoding.ASCII.GetString(bytes);
Console.WriteLine(str);