C# Class Add ID from one class to another -
i have 1 class named animal, name, type, gender, , have class named animallist, need know how can add animals animallist, class animal(im in console application): filename animal.cs
class animal { public string name {get; set;} public string type {get; set;} public string gender {get; set;} public person(string name, string type, string gender) { name = name; type = type; gender = gender; } }
and class animallist: filenameanimallist.cs
class animallist: list<animal> { should add animals list }
shouldn't better this?
public new void add(animal value) { }
instantiate animallist
class somewhere(for example in main method) , add instances of animal
class.
for example:
var animals = new animallist(); animals.add(new animal() { name = "", type = "", gender = ""});
Comments
Post a Comment