Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
1 of 1
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()} 
lomaxx
  • 116.2k
  • 58
  • 148
  • 181