Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Coding Composition
Message
De
08/08/2007 14:52:15
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Divers
Thread ID:
01246826
Message ID:
01246866
Vues:
21
Good suggestion... I just got 2.0 a little while ago, and am not completely up to date with generics.

>Hi Enrique,
>
>As Mike had pointed out, you could use ArrayLists or custom collections. You already provided a solution using arrays, which is perfectly valid as well. If you are using .NET 2.0 or superior, another alternative would be to employ generic lists, such as this:
>
>
>public class A
>{
>    IList<B> _listOfB = new List<B>();
>
>    public IList<B> ListOfB
>    {
>        get { return _listOfB;  }
>        set { _listOfB = value; }
>    }
>}
>
>public class B {}
>
>
>To use the agregation you might do the following from the user class:
>
>
>A classA = new A();
>classA.ListOfB.Add(new B());
>classA.ListOfB.Add(new B());
>classA.ListOfB.Add(new B());
>classA.ListOfB.Add(new B());
>
>
>Best regards,
Very fitting: http://xkcd.com/386/
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform