dito1710

dito1710

  • NA
  • 9
  • 0

Creting a custom collection class

Jan 24 2005 5:54 PM
Hello all, I am writing an application that will utilise a set of my own classes. I want to create another class that acts as a collection of my class. For example I could have a class "User". At some point in my application I may need to instanciate x objects of class "User". I would like to create a class called "UserCollection" which could then be used to group all x "User" objects so that when neccesary I could itterate through the "UserCollection" object like..... UserCollection myUsers = new UserColection(); User myUser1 = new User(a,b); myUsers.Add(myUser1); User myUser2 = new User(c,d); myUsers.Add(myUser2); User myUser3 = new User(e,f); myUsers.Add(myUser3); User myUser4 = new User(g,h); myUsers.Add(myUser4); .... User myUser13 = new User(y,z); myUsers.Add(myUser13); foreach(User currentUser in myUsers) { currentUser.callMethod1(); } Is there sample code around for doing this? Thanks

Answers (2)