I need to have a property in my model that will store it's date of creation. It looks like this:
public class User
{
public User()
{
this.DateCreated = DateTime.Now;
}
public int Id { get; set; }
public string Name { get; set; }
public DateTime DateCreated { get; set; }
}
My question is particularly about the assignment of the DateCreated property in the constructor of the model:
public User()
{
this.DateCreated = DateTime.Now;
}
It works fine but I'm just wondering whether this approach is correct, as I wasn't able to find anything about it.