Değil Hakkında Gerçekler bilinen C# IList Nerelerde Kullanılıyor

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.

Arec BarrwinArec Barrwin 61.8k99 gold badges3030 silver badges2525 bronze badges 14 71 I have to disagree with your sardonic answer. I don't totally disagree with the sentiment of over-architecture being a real mesele. However I think that especially in the case of collections that interfaces really shine.

Interface’ler üzerine daha bir araba bilgelik peyda etmek isterseniz, zirdaki kaynaklara nazar atabilirsiniz:

Kendi koleksiyon sınıflarınızı oluştururken yeni baştan kullanılabilir kod yazmanızı esenlar: C# CollectionBase kullanarak umumi derlem nöbetlemlerini karınermiş bir kök klas oluşturabilirsiniz.

In this specific case since you're essentially talking about a language construct, not a custom one it generally won't matter, but say for example that you found List didn't support something you needed.

The speed difference is sufficiently great that in many cases it may be faster to copy a list to an array, sort the array, and copy the list back, than to try to have a sort routine process the list in place.

List implements IList, and so birey be assigned to the variable. There C# IList Neden Kullanmalıyız are also other types that also implement IList.

 

If you started with a concrete type and you decided to change to another one, even if it uses the same C# IList Neden Kullanmalıyız 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

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

Bir sonraki C# IList Nasıl Kullanılır elementin varlığını sınayan MoveNext ve geçerli elementi veren GetCurrent metodlarına sahiptir.

Brad LeachBrad Leach 17k1818 gold badges7373 silver badges8888 bronze badges 1 3 It will create a new enumerable, which may hamiş be desirable in some scenarios. You cannot sort an IList in-place through the interface except by using ArrayList.Adapter method in my knowledge.

I have two ILists of the same type returned by NHibernate and have emerged the two IList into one, hence the need for sorting.

additional advantage is that your code is C# IList Nedir safe from any changes to concrete class birli you are subscribing to only few of the methods of concrete class and those are the ones that are going to be there kakım long birli the concrete class inherits from the interface you are C# IList Neden Kullanmalıyız using.

Leave a Reply

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