====== Encodings ====== Since all strings in .NET are Unicode strings (see [[string_char_byte|String, Char and Byte]], you need to use the right encoding when reading and writing (disk, network, database). For the Encodings please see the classes that inherit from the [[https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding|System.Text.Encoding]] class: * System.Text.ASCIIEncoding: 7 bit ASCII * System.Text.UnicodeEncoding: UTF-16 Unicode * System.Text.UTF32Encoding: UTF-32 Unicode * System.Text.UTF7Encoding: UTF-7 Unicode * System.Text.UTF8Encoding: UTF-8 Unicode The Encoding class has a few very interesting static methods (please see MSDN for further details): * Convert converts a byte array from one encoding to another * GetBytes converts a character array or a string to a byte array * GetChars converts a byte array to a char array * GetString converts a byte array to a string It may sound difficult, but it is neccessary to understand the encodings when you deal with different systems (disk, database, network). Otherwise you will corrupt your data.