csharp store byte array as string

Code Example - csharp 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);
    }
                    
                
 

convert system.byte a string csharp

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

convert bytes to string and back csharp

                        
                                string base64 = Convert.ToBase64String(bytes);
byte[] bytes = Convert.FromBase64String(base64);
                            
                        
 

csharp string to byte array

                        
                                string author = "Mahesh Chand";  
// Convert a C# string to a byte array  
byte[] bytes = Encoding.ASCII.GetBytes(author);  

// Convert a byte array to a C# string. 
string str = Encoding.ASCII.GetString(bytes);
                            
                        
 

csharp byte array to string

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