Class & Struct

2019-01-27  本文已影响0人  津涵

1. class & struct

class : heat ~ reference
struct : stack ~ value

2. readonly(需要分配static修饰符)

具有只读修饰符的字段只能从构造函数中分配初始值,这与const修饰符不同
Declaring the field with the readonly modifier only allows initializing the value of the property in the constructor.
With the readonly modifier, the compiler complains if the state is changed

3.uint

无符号32位整数

4.get/set方法

((我们不指定get/set方法参数))

5.get/set ~简约写法

public int Age{get;set;}
(1)The declaration of a private field is not needed.
(2)其中一个方法的类别必须与变量一直,即为public;
((set的类别可设为private或protected))

上一篇下一篇

猜你喜欢

热点阅读