How to make constructor to set current date + 5 days?

I am stuck with a task where it is required to make a constructor sets the current date + 5 days as the ShelfDate property value.

public DateTime ShelfDate { get; set; } 
public Food(int id, string name, decimal price, DateTime shelfDate) : base(id, name, price)
{
    shelfDate = DateTime.Today.AddDays(5);
    ShelfDate = shelfDate;
}

But, prop ShelfDate displays 1/1/0001 12:00:00 AM and not today's date + 5 days. Why?



Read more here: https://stackoverflow.com/questions/67375512/how-to-make-constructor-to-set-current-date-5-days

Content Attribution

This content was originally published by Hanna at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: