I currently have this:
function SystemCollection () {
this.systems = [];
this.getSystem = function (id) {
for(var s in this.systems) {
if(s.num == id)
return s;
};
return null;
};
this.add = function (system) {
this.systems.push(system);
};
this.count = systems.length;
};
In C#, I'd do something like this:
class SystemCollection {
private List<System> _foo = new List<System>();
public System this[int index]
{
get { _foo[index]; }
}
public System this[string name]
{
get { return _foo.Where( x => x.Name == name).SingleOrDefault(); }
}
}