C# Automatic Properties - Why Do I Have To Write “get; set;”?

后端 未结 9 1978
失恋的感觉
失恋的感觉 2020-12-29 01:33

If both get and set are compulsory in C# automatic properties, why do I have to bother specifying \"get; set;\" at all?

9条回答
  •  无人及你
    2020-12-29 02:00

    The compiler needs to know if you want it to generate a getter and/or a setter, or perhaps are declaring a field.

提交回复
热议问题