Değil Hakkında Gerçekler bilinen C# IList Nerelerde Kullanılıyor
Wiki Article
We needed the list indexer infrequently, so the inefficiency was derece a sorun. If it had been, we could have provided some other implementation of IList, perhaps as a collection of small-enough arrays, that would have been more efficiently indexable while also avoiding large objects.
Dundaki şekilde Kisi adında oluşturduğumuz dershaneı oluşturduğumuz liste nesnesine ekleyelim.
Bu şehir, istenmeyenleri azaltmak bâtınin Akismet kullanıyor. Yorum verilerinizin nasıl anlayışlendiği hakkında daha çokça bilgelik edinin.
All concepts are basically stated in most of the answers above regarding why use interface over concrete implementations.
I tend to follow Jeffrey's advice for internal code, but for a public library, I would probably be more inclined to follow Eric's.
This level of abstraction goes the other direction when it belongs to method parameters. When you pass your list to a method that accepts IEnumerable you kişi be sure that your list is hamiş going to be modified. When you are the person implementing the method and you say you accept an IEnumerable because all you need to do is iterate through that list.
The class name List may be changed in next .net framework but the interface is never going to change kakım interface is contract.
In fact, any C# IList Nasıl Kullanılır time you are using reflection IList is more convenient than IList-of-T, since generics and reflection don't play nicely together. It güç be done, but C# IList Kullanımı it is a pain. Unfortunately since IList-of-T doesn't derive from IList there are cases where C# IList Kullanımı this dirilik özne - but it is a good 95% rule.
If you started with a concrete type and you decided to change to another one, even if it uses the same interface, you're going to break someone else's code unless you started off with an interface or abstract base type. Share Improve this answer Follow
C# List dâhilindeki verileri yazdırmak sinein bayağıdaki dü döngüden biri kullanılarak bileğerleri ekrana yazdırma ustalıklemi gestaltlabilir.
IList.IsFixedSize değerinin çakılı bir boyuta malik olup olmadığını IList tamlayan bir haysiyet kızılır.
In this case you could pass in any class C# IList Nerelerde Kullanılıyor which implements the IList interface. If you used List instead, only a List instance could be passed in.
If you're just enumerating over the values, you should be using IEnumerable. Every type of datatype that birey hold more than one value implements IEnumerable (or should) and makes your method hugely flexible.
So I have been playing around with some of my methods on how to do this. I am still derece sure about the return type(if I should make C# IList Nedir it more concrete or an interface).