c# - Way to have a class Schedule behaving like List<DateTime>? -
this question has answer here:
- overloading assignment operator in c# 3 answers
i have:
public class schedule { public list<datetime> dates {get; set;} // methods }
i'd schedule behave list:
var date = schedule[idx]; dates = list<datetime>; schedule = dates; dates = schedule; ...
schedule should list of dates in reality, adding member dates, feels computer object, adding layer of abstraction , moving away modeled object.
there 2 possibilities not perfect:
overloading operators (e.g. "[]") "="can't overloaded.
alias "using" won't have method.
for example, in c++, have overloaded operators , keep private member _dates.
thanks
if schedule is list of dates, make one:
public class schedule : list<datetime> { // more stuff } schedule myschedule = new schedule(); myschedule.add(datetime.now);
Comments
Post a Comment