rmatthew Posted March 5, 2006 Posted March 5, 2006 I have a class that has within it subclasses... I am trying to implement a collection of those subclasses as a property of the top most class such that I can utilize a .add() type funcation. such as follows: dim dt as datatable dt.rows.add(dt.newrow) I would like to use this strucature with my classes I have implemented IEnumerator, IEnumerable etc. and am pretty happy with the results - just need this last little thing :) Help Could be that I am working on little sleep... Quote
Cags Posted March 5, 2006 Posted March 5, 2006 You can create a strongly typed collection class (for storing the subclasses) with an add method. Then create a property of that class in the main class. // pseudo code public class Team { public PlayerCollection Players { get { return _players; } set { _players = value; } } } public class Player { } public class PlayerCollection : CollectionBase { public void Add(Player obj) { } } Quote Anybody looking for a graduate programmer (Midlands, England)?
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.