Skip to main content
Post Made Community Wiki by CommunityBot
Source Link
lomaxx
  • 116.2k
  • 58
  • 148
  • 181

Two things I like are Automatic properties so you can collapse your code down even further:

private string _name; public string Name { get { return _name; } set { _name = value; } } 

becomes

public string Name { get; set;} 

Also object initializers:

Employee emp = new Employee(); emp.Name = "John Smith"; emp.StartDate = DateTime.Now(); 

becomes

Employee emp = new Employee {Name="John Smith", StartDate=DateTime.Now()}