C# IList Nerelerde Kullanılıyor Için 5-İkinci Trick

driisdriis 163k4545 gold badges268268 silver badges343343 bronze badges 3 Sorry, but even now there are plenty of uses for library code to use IList (non-generic). Anyone who says otherwise hasn't suffered enough reflection / data-binding / etc ;)

1 @supercat: What could ISortableList offer that's not already in IList? Or, asked differently, why couldn't an IList be sorted in-place without re-adding the items by your imagined static method?

Bir dahaki sefere yorum yaptığımda kullanılmak üzere etapı, elektronik posta adresimi ve web şehir adresimi bu tarayıcıevet kaydet.

Your functions above only care about being able to iterate over a list. Ideally they shouldn't need to know who implements that list or how they implement it.

This will allow me to do generic processing on almost any array in the .Kupkuru framework, unless it uses IEnumerable and not IList, which happens sometimes.

so its safety for you and freedom to the coder who is writing concrete implementation to change or add more functionality to his concrete class.

List implements IList, and so birey be assigned to the variable. There are also other types that also implement IList.

In fact, any time you are using reflection IList is more convenient than IList-of-T, since generics and reflection don't play nicely together. It kişi be done, but it is a pain. Unfortunately since IList-of-T doesn't C# IList Neden Kullanmalıyız derive from IList there are cases where this hayat işleyen - but it is a good 95% rule.

In most cases, if you are using a List and you think you could use a narrower interface instead - why derece IEnumerable? This is often a better fit if you don't need to add items. If you need to add to the collection, use the concrete type, List.

What US checks C# IList Nerelerde Kullanılıyor and balances prevent the FBI from raiding politicians unfavorable to the federal government? more hot questions

Bir sonraki elementin varlığını sınayan MoveNext ve meri elementi veren GetCurrent metodlarına sahiptir.

You might want to have an IOrderRepository that defines a collection of orders C# IList Neden Kullanmalıyız in either a IList or ICollection. You C# IList Nasıl Kullanılır could then have different kinds of implementations to provide a list of orders birli long birli C# IList Neden Kullanmalıyız they conform to "rules" defined by your IList or ICollection.

If you use the concrete type all callers need to be updated. If exposed kakım IList the caller doesn't have to be changed.

There is a complication though that dynamic dirilik't see explicit implementations, so something gönül implement IList and IList-of-T and yet still be completely unusable from dynamic.

Leave a Reply

Your email address will not be published. Required fields are marked *