DEğIL HAKKıNDA DETAYLAR BILINEN C# ILIST KULLANıMı

Değil Hakkında Detaylar bilinen C# IList Kullanımı

Değil Hakkında Detaylar bilinen C# IList Kullanımı

Blog Article

We needed the list indexer infrequently, so the inefficiency was hamiş 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.

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?

Here's an example: I had a project once where our lists got very large, and resulting fragmentation of the large object heap was hurting performance. We replaced List with LinkedList. LinkedList does derece contain an array, so all of a sudden, we had almost no use of the large object heap.

All concepts are basically stated in most of the answers above regarding why use interface over concrete implementations.

swilliamsswilliams 48.6k2727 gold badges101101 silver badges130130 bronze badges 3 5 why hamiş make it a just a List in the first place? I still don't understand why bonus you get from making it a IList then in the constructor you make it into a List

The Liskov Substitution Principle (simplified) states that a derived type should be able to be used in place of a base type, with no additional preconditions or postconditions.

The cost to do this is minimal, why derece save yourself the headache later? It's what the interface principle is all about.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

the method, it sevimli 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.

If you yaşama consider your method, determine that you probably won't be changing the return collection type, then C# IList Neden Kullanmalıyız it is probably safe to return a more exact type. If you aren't sure, or are afraid that if you change it in future you'll be breaking other people's code, then go C# IList Nasıl Kullanılır more general.

It is like this other question. The other question shares a lot of common ground, but is arguably not a true duplicate. In either case though, this is hamiş opinion-based. What may have happened is that the closer might have just looked at this question's title, without reading C# IList Nasıl Kullanılır the question itself. The body is objective.

Collaborate with us on GitHub The source for this content dirilik be found on GitHub, where you gönül also create and review issues and pull requests. For more information, C# IList Kullanımı see our contributor guide.

In collections of contiguous elements, such as lists, the elements that follow the insertion point move down to accommodate the new element.

This works, because only the outer list is created in the first C# IList Neden Kullanmalıyız place. You dirilik then insert individual items that are compatible with IList:

Report this page