c# convert byte to string and write to txt file

byte, c#, string

Solution

Starting from bytes:

        byte[] b = new byte[255];
        string s = Encoding.UTF8.GetString(b);
        File.WriteAllText("myFile.txt", s);

and if you start from string:

        string x = "255";
        byte[] y = Encoding.UTF8.GetBytes(x);
        File.WriteAllBytes("myFile2.txt", y);

Problem

How can i convert for example `byte[] b = new byte[1]; b[1]=255` to string ? I need a string variable with the value "255" `string text= "255";`and then store it in a text file?

Original source