码迷,mamicode.com
首页 > Windows程序 > 详细

C# 知识巩固二

时间:2019-12-09 21:47:49      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:链接   present   locate   get   ace   variable   static   require   variables   

几种类型所占的空间大小

类型 空间占用(字节)
byte 1
short 2
int 4
long 8
char 2
float 4
double 8
decimal 16
bool 1

一个字节等于8比特(1byte=8bit).

注意:在C# 中 bool类型不能转换为int类型


存储在类型中的信息包括

  • The storage space that a variable of the type requires.(类型变量所需的存储空间)

  • The maximum and minimum values that it can represent.(它能表示的最大值和最小值)

  • The members (methods, fields, events, and so on) that it contains.(它包含的成员(方法、字段、事件等))

  • The base type it inherits from.(它继承的基本类型)

  • The location where the memory for variables will be allocated at run time.(运行时将分配的变量的位置)

  • The kinds of operations that are permitted.(运行的操作种类)


 

静态成员始终按类名(而不是实例名称)进行访问。


 

隐式转换不需要特殊语法,因为转换是类型安全的,并且不会丢失任何数据。

参考链接:

微软官方文档 sizeof 运算符

微软官方文档 Type

微软官方文档 静态类和静态类成员

微软官方文档 转换和类型转换

 

C# 知识巩固二

标签:链接   present   locate   get   ace   variable   static   require   variables   

原文地址:https://www.cnblogs.com/wu-xin/p/12013383.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!