C# Automatic Properties

前端 未结 11 1117
有刺的猬
有刺的猬 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:19

    It is meant that you expect to add the logic later.

    If you do so and have it as property from the beginning, you will not have to rebuild the dependent code. If you change it from a variable to a property, then you will have to.

提交回复
热议问题