4
Answers

How do I implement a method like myCountry.Towns.Add();

Eric Brough

Eric Brough

10y
955
1


I have a class called Country.  I can instantiate it by Country myCountry = new County();


It has method, AddTown(string townName) { ... }  which can be called like myCountry.AddTown("London");


How can I add an alternative method with identical functionality but which is called like myCountry.Towns.Add("London");


I cant figure out how to implement the '.Towns.' part of the naming structure.




Answers (4)