Why Automatically implemented properties must define both get and set accessors

前端 未结 3 1821
-上瘾入骨i
-上瘾入骨i 2020-12-15 03:12

When we define a property like

    public string Name {get; set;}

dot net can make our properties code. but when we use

            


        
3条回答
  •  感动是毒
    2020-12-15 04:01

    If there is no setter, the property can never have anything other than the default value, so doesn't serve any purpose.

提交回复
热议问题