Shorthand Accessors and Mutators
问题 I am learning C#, and am learning about making fields private to the class, and using Getters and Setters to expose Methods instead of field values. Are the get; set; in Method 1 and Method 2 equivalent? e.g. is one a shorthand of the other? class Student { // Instance fields private string name; private int mark; // Method 1 public string Name { get; set; } // Method 2 public int Mark { get { return mark; } set { mark = value; } } } Finally, would Method 2 be used when you want to for