8.2.1 Predefined types

王朝other·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

8.2.1 Predefined types

C# provides a set of predefined types, most of which will be familiar to C

and C++ developers.

The predefined reference types are object and string. The type object is

the ultimate base type of all

other types. The type string is used to represent Unicode string values.

Values of type string are

immutable.

The predefined value types include signed and unsigned integral types,

floating-point types, and the types

bool, char, and decimal. The signed integral types are sbyte, short, int,

and long; the unsigned

integral types are byte, ushort, uint, and ulong; and the floating-point

types are float and double.

The bool type is used to represent boolean values: values that are either

true or false. The inclusion of bool

makes it easier to write self-documenting code, and also helps eliminate

the all-too-common C++ coding

error in which a developer mistakenly uses .=. when .==. should have been

used. In C#, the example

int i = .;

F(i);

if (i = 0) // Bug: the test should be (i == 0)

G();

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有  導航