C# Save from list -
hello have 1 class called animal.cs , in program.cs have created animals..
class program { static void main(string[] args) { var animallist = new animsllist(); animallist.add(new animal{ active = true, name = "bob", photo = "espanha" }); animallist.add(new animal { active = false, name = "robby", photo = "portugal" }); animallist.add(new animal { active = true, name = "snoop", photo = "uk" }); } }
and have 1 class animallist.cs , in class added animal list, , im getting active animals code:
class animallist : list<animal> { public list<animal> getactiveanimals() { return this.findall(p => p.active); } }
and problem in class called event.cs in event.cs want results getactiveanimals() because want active animals event can me please?
class event { private animallist _contestants; }
i should active animalist in 1 above. active ones should go _contestants
extend event constructor example
class event { private animallist _contestants; public event(animallist contestants) { _contestants = contestants; } }
and forward list when create event:
static void main(string[] args) { var animallist = new animsllist(); animallist.add(new animal{ active = true, name = "bob", photo = "espanha" }); animallist.add(new animal { active = false, name = "robby", photo = "portugal" }); animallist.add(new animal { active = true, name = "snoop", photo = "uk" }); var event = new event(animallist.getactiveanimals(); }
Comments
Post a Comment