Im getting the following error:
You cannot use the local variable 'dob' before it is declared
Here is my implementation
public class Person
{
...
public string dob { get; set; }
...
public int getAge()
{
DateTime origin = DateTime.Parse(dob);
return DateTime.Today.Year - origin.Year;
}
public string getFormattedDoB()
{
DateTime origin = DateTime.Parse(dob);
string dob = origin.ToString("d");
return dob;
}
}
I'm not sure what to do with this, because he complains about using dob in getFormattedDoB(), but not in getAge(), which precedes it. If anyone could shed light on this, that would be great
source
share