这是我一直遇到的情景。我希望所有的公共属性都在ctor中分配,但只是小写的第一个字母。有没有办法做到这一点?
class User
{
public int ID { get; }
public string Name { get; }
public string Initials { get; }
public DateTime LastLogOn { get; }
public Role Role { get; }
public User (int ID, string name, string initials, DateTime lastLogOn, Role role)
{
Name = name;
Initials = initials;
LastLogOn = lastLogOn;
Role = role;
}
}