Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Property Get Runs When Class Instantiated
Message
De
09/04/2009 16:23:20
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01394040
Message ID:
01394046
Vues:
42
>I have a property on a Company class:
>
>
>private ArrayList _colClients = new ArrayList();
>public ArrayList colClients
>{
>    get
>    {
>        if (_colClients.Count == 0)
>        {
>            _LoadClients();
>        }
>        return _colClients;
>    }
>}
>
>
>When I instantiate the class, the colClients collection is being loaded. I put a breakpoint on the IF() inside the Get, but it doesn't break. Yet when I look at colClients.Count, it's set to 3 instances of a Client class.
>
>Anyone know why the Get assesor is firing when the class is instantiated?

Search your class for any references to "colClients".
Very fitting: http://xkcd.com/386/
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform