C# class properties

The code below shows the short hand and long hand syntax for defining class properties.

public class Example
{
  // class property short hand
  public string Firstname {get; set;}


  // class property long hand
  private string _Lastname;
  public string Lastame
  {
     get {return _Lastname}
     set {_Lastname = value}
  }
}

Leave a Reply