美文网首页
Class & Struct

Class & Struct

作者: 津涵 | 来源:发表于2019-01-27 12:53 被阅读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))

    相关文章

      网友评论

          本文标题:Class & Struct

          本文链接:https://www.haomeiwen.com/subject/iamgjqtx.html