c# - Way to have a class Schedule behaving like List<DateTime>? -


this question has answer here:

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

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -