Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying To Understand Indexers
Message
 
À
10/11/2009 00:31:56
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01433919
Message ID:
01434073
Vues:
43
LOL. That's not ery encouraging. I guess I'm really lost on Indexers. let me just ask this: What's the point of an indexer? How/why would you use one?



>Sorry Kevin, maybe it's just me, but your code snippets aren't making too much sense to me. Yeah, I've had a long day (moved back home to WA today), and so maybe I'm just tired. But I'm not getting it. Could you try explaining it again, with better code snippets?
>
>Thx,
>~~Bonnie
>
>
>
>>I have this customer class:
>>
>>
>>public class Customer
>>{
>>    private List<Invoice> _Invoices = new List<Invoice>();
>>    public Invoice this[int item]
>>    {
>>        get
>>        {
>>            return _Invoices[item];
>>        }
>>        set
>>        {
>>            _Invoices[item] = value;
>>        }
>>    }
>>}
>>
>>
>>I then do this:
>>
>>
>>static void Main(string[] args)
>>{
>>    Invoice InvA = new Invoice();
>>    InvA.InvoiceId = "A0001";
>>
>>    Invoice InvB = new Invoice();
>>    InvB.InvoiceId = "B0002";
>>
>>    Customer cust = new Customer();
>>    cust[0] = InvA;
>>    cust[1] = InvB;
>>}
>>
>>
>>I'm not really seeing a usage for indexers. It seems to me that an Invoices collection would be better. What's the point of indexers?
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform