Set properties of a class only through constructor

前端 未结 5 2006
野趣味
野趣味 2021-01-01 11:39

I am trying to make the properties of class which can only be set through the constructor of the same class.

5条回答
  •  死守一世寂寞
    2021-01-01 11:50

    As of c# 6.0 you now can have get only properties that can be set in the constructor (even though there is no set defined in the property itself. See Property with private setter versus get-only-property

提交回复
热议问题