convert system.byte a string csharp

Code Example - convert system.byte a string csharp

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

csharp bytes to string

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

string from byte array csharp

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

convert bytes to string and back csharp

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

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);
    }
                            
                        
 

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);