I have an DateTime property field in a struct. I'm trying to validate the inputdate to make sure the value entered is not in the future.
i'm using the following code:
public struct Car
{
public DateTime Year
{
get
{
return Year;
}
set
{
if (value > DateTime.Now)
throw new InvalidOperationException("Date cannot be in the futrure");
else
Year = value;
}
}
}
When i now try to run this code i keep getting a StackOverflowException with the message "Cannot evaluate expression because the current thread is in a stack overflow state."
any ideas on why this is, or how to fix this?
-Thanks.