how to convert byte array to string in c# code example

Example 1: convert system.byte a string c#

string result = System.Text.Encoding.UTF8.GetString(byteArray);

Example 2: c# store byte array as string

public static void Main()
    {
        byte[] bytes = Encoding.Default.GetBytes("ABC123");
        Console.WriteLine("Byte Array is: " + String.Join(" ", bytes));
 
        string str = Encoding.Default.GetString(bytes);
        Console.WriteLine("The String is: " + str);
    }

Example 3: string from byte array c#

var str = System.Text.Encoding.Default.GetString(result);

Example 4: c# store byte array as string

string bitString = BitConverter.ToString(bytes);