C# Automatic Properties

前端 未结 11 1142
有刺的猬
有刺的猬 2020-12-05 03:57

I\'m a bit confused on the point of Automatic properties in C# e.g

public string Forename{ get; set; }

I get that you are saving code by no

11条回答
  •  孤街浪徒
    2020-12-05 04:41

    For one, you can set the property to virtual and implement logic in an inheriting class. You can also implement logic in the same class afterwards and there won't be side-effects on any code relying on the class.

提交回复
热议问题