csharp get bytes from string

Code Example - csharp get bytes from string

                
                        byte[] bytes = Encoding.ASCII.GetBytes(someString);
                    
                
 

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

Related code examples