带有“static”修饰符声明的变量称为静态变量。一旦静态变量所属的类被加载,直到包含该类的程序运动结束时它将一直存在。静态变量的初始值就是该变量类型的默认值。为了便于赋值检查,静态变量最好在定义时赋值。如 static int a = 10;
| 类型 | ||
|---|---|---|
| 静态变量 | static int a=10; | 静态变量的一旦加载,将持续到程序结束 |
| 非静态变量 | 不带 static 修饰的变量 | |
| 数组元素 | 随数组实例的存在而存在 | |
| 值参数 | ||
| 引用参数 | ||
| 输出参数 | ||
| 局部变量 | 在一个独立的程序块内定义的变 |
attributes constant-modifiers const type |
public const int a = 100; |
| constant-modifyiers(常量修饰符) | 意义 |
|---|---|
| new | |
| public | 公有 |
| protected | 保护 |
| internal | |
| private | 私有 |
| sbyte, byte, shoft, ushort, int, uint, long, ulong, char, float, decimal, bool, string, enum-type, reference-type |