M
Michael Hanson
In a simple time class, int hour
/*
public int Hour // This works
{
get { return hour; }
set { hour = value; }
}
*/
// Automatic property?
public int Hour { get; set; } // This doesn't set hour !
// Client code
Time t = new Time(now);
int theHour = t.Hour;
Console.WriteLine("\nRetrieved the hour: {0}\n", theHour);
theHour++;
Console.WriteLine("\nUpdated the hour: {0}\n", theHour);
/*
public int Hour // This works
{
get { return hour; }
set { hour = value; }
}
*/
// Automatic property?
public int Hour { get; set; } // This doesn't set hour !
// Client code
Time t = new Time(now);
int theHour = t.Hour;
Console.WriteLine("\nRetrieved the hour: {0}\n", theHour);
theHour++;
Console.WriteLine("\nUpdated the hour: {0}\n", theHour);