Conversion of Byte array into a C# String

In this article we will discuss about how to convert the byte array into corresponding hexadecimal string in C#.
  • 5469

In this article we are discussing about how to convert an byte array into string value and to do this we will use System.BitConverter Class which converts base data type into an array of bytes and vise and versa. It has various methods one of which is ToString(Byte[]) which converts the numeric value of each element of a specified array of bytes to its corresponding string representation.

Lets have a look on the following example:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;


namespace ConsoleApplication15


    class Program


        static void Main(string[] args)


            byte[] value = { 0x02, 0xAB, 0xC1, 0xCD, 0x12, 0xDE };


            string str1 = BitConverter.ToString(value);



            str1 = BitConverter.ToString(value).Replace("-", "");








Ask Your Question 
Got a programming related question? You may want to post your question here


More Articles

© 2020 DotNetHeaven. All rights reserved.