Do I need to use { get; set; } with c# fields that have no special actions when getting and setting

前端 未结 8 1340
借酒劲吻你
借酒劲吻你 2021-01-16 04:59

I have been coding classes like this:

public class ReportViewModel
    {
        public string Status;
        public string DataSource;
        public Stri         


        
8条回答
  •  猫巷女王i
    2021-01-16 05:37

    When you don't add the get and set you are using a field rather than a property. Which in many cases won't make a lot of difference. However, you can't databind to a field like you can with a Property. So you would lose that.

提交回复
热议问题