Benim C# IList Kullanımı Başlarken Çalışmak

Note that, if your API is only going to be used in foreach loops, etc, then you might want to consider just exposing IEnumerable instead.

What US checks and balances prevent the FBI from raiding politicians unfavorable to the federal government?

The less popular answer is programmers like to pretend their software is going to be re-used the world over, when infact the majority of projects will be maintained by a small amount of people and however nice interface-related soundbites are, you're deluding yourself.

Bearing this in mind, it makes most sense to pass types with the least number of external dependencies possible and to return the same. However, this could be different depending on the visibility of your methods and their signatures.

Use whatever you want. It's your method. You're the only one who gets to see the internal implementation details of the method.

List is a specific implementation of IList, which is a container that hayat be addressed the same way as a linear array T[] using an integer index. When you specify IList birli the type of the method's argument, you only specify that you need certain capabilities of the container. For example, the interface specification does derece enforce a specific veri structure to be used.

Bu şehir, istenmeyenleri azaltmak midein Akismet kullanıyor. Tefsir verilerinizin nasıl meselelendiği karşı henüz bir küme bilgelik edinin.

3 @phoog: Considering where Eric is coming from, it wouldn't be surprising he is more cautious about breaking C# IList Neden Kullanmalıyız changes. But it is definitely a valid point.

the method, it dirilik make a huge difference -- if they have an array and you're asking for a list, they have to change the array to a list or v.v. whenever calling the method, a total waste of time from both a programmer and performance POV.

List implements those nine methods C# IList Nedir (not including extension methods), on toparlak of that it katışıksız about 41 public methods, which weighs in your consideration of which one to use in your application.

Bayağıdaki şekilde Kisi isminde oluşturduğumuz klası oluşturduğumuz liste nesnesine ekleyelim.

rajeshrajesh 39133 silver badges22 bronze badges 1 C# IList Neden Kullanmalıyız 8 Excellent, clear answer, which I marked bey helpful. However, I would add that for most developers, most of the time, the tiny difference in C# IList Nerelerde Kullanılıyor yetişek size and performance is hamiş worth C# IList Nasıl Kullanılır worrying about: if in doubt, just use a List.

And, if you used a generic implementation, you would only be able to use a method that works for any object only with objects of a specific type.

Encapsulation relies on telling clients as little about the implementation of your class as possible. If you return a concrete List, you kişi't then change to some other better type without forcing all of your clients to re-compile/update.

Leave a Reply

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