I'm assuming I'm pretty close. I have a value StartedAgent
that will contain a specific date entered by the user. Lets say they entered "1/1/1985" I then want to create a calculated property that I can use to display how many years since this agent first started working in Real Estate. Below is my class. I have tried to take a stab at it, but I'm coming up short. I'm using MVC 5, EF 6 & .Net 4.5 in the flavor of C#.
namespace OrlandoAppraiser.Models
{
public class Appraiser
{
public int AgentID { get; set; }
public string Name { get; set; }
public string LicenseNum { get; set; }
public DateTime StartedAgent { get; set; }
public string YearsAsAgent
{
get { return (Math.Floor((DateTime.Now - StartedRealEstate).TotalDays / 365.25D)); }
}
}
}
I have looked at some different answers, but I'm having trouble finding a way of doing this simple inside a calculated property. I know it shouldn't be that much different, but I'm getting errors with my code.