public int this[string str]
{
get
{
switch (str.ToLower())
{
case "year":
return Year;
case "month":
return Month;
case "day":
return Day;
default:
throw new ArgumentOutOfRangeException("index = " + str);
}
}
set
{
switch(str.ToLower())
{
case "year":
Year = value;
break;
case "month":
Month = value;
break;
case "day":
Day = value;
break;
default:
throw new ArgumentOutOfRangeException("index = " + str);
}
}
}