logo
CSharp_Prog_Guide

Безопасность

Для проверки данных, введенных пользователем в такие элементы управления, как текстовые поля и поля со списком, всегда следует использовать метод TryParse или Parse.

Encoding Base Types

Characters are abstract entities that can be represented using many different character schemes or code pages. For example, Unicode UTF-16 encoding represents characters as sequences of 16-bit integers, whereas Unicode UTF-8 represents the same characters as sequences of 8-bit bytes. The common language runtime uses Unicode UTF-16 (Unicode Transformation Format, 16-bit encoding form) to represent characters.

Applications that target the common language runtime use encoding to map character representations from the native character scheme to other schemes. Applications use decoding to map characters from non-native schemes to the native scheme. The following table lists the most commonly used classes in the System.Text namespace to encode and decode characters.

Character Scheme

Class

Explanation

ASCII encoding

System.Text..::.ASCIIEncoding

Converts to and from ASCII characters.

Multiple encoding

System.Text..::.Encoding

Converts characters to and from various encodings as specified in the Convert method.

UTF-16 Unicode encoding

System.Text..::.UnicodeEncoding

Converts to and from UTF-16 encoding. This scheme represents characters as 16-bit integers.

UTF-8 Unicode encoding

System.Text..::.UTF8Encoding

Converts to and from UTF-8 encoding. This variable-width encoding scheme represents characters using one to four bytes.