operator [] method
Retrieves the value of a specific date part.
Parameters:
part(DatePart, required): The date part to retrieve.
Returns: The value of the specified part, or null if not set.
Implementation
int? operator [](DatePart part) {
switch (part) {
case DatePart.year:
return year;
case DatePart.month:
return month;
case DatePart.day:
return day;
}
}