Auto populate properties in class

  Uncategorised

Suppose that I have a class name User, is there any ways to populate the class properties and default value in Visual Studio as follow. I feel it is tedious to repeat typing the properties again and again.

Probably there is default shortcut to do this in Visual Studio or any extension that can do this?

Case 1

var user = db.User.Where(x => x.UserID).Select(o => new User
{
   UserId = o.UserId, // auto populate
   Username = o.Username, // auto populate
   ........  // auto populate all properties inside User class
}
);

case 2

var user = new User();
user.UserID = "",  // auto populate with type default value
user.Username = "",  // auto populate with type default value
........ // auto populate all properties inside User class
........ // auto populate all properties inside User class

Source: Visual Studio Questions

LEAVE A COMMENT