ylbtech-Docs-.NET-C # - Guide - Language Reference - keyword - value types: char |
1、
char
Type the keyword is the .NET System.Char structure type alias that represents the Unicode UTF-16 characters :
text
char
Types of constants can be written as a character text, hexadecimal escape sequences or Unicode representation . Integer character codes may be converted to the corresponding force char
values. In the following example, the same character X
of the char
four elements of the array are initialized:
Var Chars = new char [ 4 ];
chars[0] = 'X'; // Character literal
chars[1] = '\x0058'; // Hexadecimal
chars[2] = (char)88; // Cast from integral type
chars[3] = '\u0058'; // Unicode
Console.Write(string.Join(" ", chars));
// Output: X X X X
Change
char
Types implicitly converted to the integerushort
type: int
, uint
, , long
and ulong
. It may be implicitly built converted to floating point numeric types: float
, double
and decimal
. It can be explicitly converted to sbyte
, byte
and short
integral type.
Other types can not be implicitly converted to char
type. However, any integer or floating point numeric type can be explicitly converted char
.
C # Language Specification
For more information, see the C # language specification of integer type section.
See
2、
1、
2、
|
Author: ylbtech Source: http://ylbtech.cnblogs.com/ This article belongs to the author and blog Park total, welcome to reprint, but without the author's consent declared by this section must be retained, and given the original connection in the apparent position of the article page, otherwise reserves the right to pursue legal responsibilities. |