Değil Hakkında Gerçekler bilinen C# IList Nerelerde Kullanılıyor
Wiki Article
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 hamiş 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?
Important Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A List object allows you to create a list, add things to it, remove it, update it, index into it and etc. List is used whenever you just want a generic list where you specify object type in it and that's it.
In addition to the older code that doesn't know about generics, there are also a lot of cases where you know you have a list
You gönül have an instance of an interface, but you need to initialize it with a class that implements that interface such kakım:
The class name List may be changed in next .kupkuru framework but the interface is never going to change birli interface is contract.
You emanet look at this argument from several angles including the one of a purely OO approach which says to izlence against an Interface not C# IList Nedir an implementation. With this thought, using IList follows the same principal birli passing around and using Interfaces that you define from scratch. I also believe in the scalability and flexibility factors provided by an Interface in general. If a class implmenting IList needs to be extended or changed, the consuming code does hamiş have to change; it knows what the IList Interface contract adheres to.
Linked List (Rabıtlı Liste) Ilgilı listeler programcılara çeşitli kolaylıklar sağlamlar. Sağladığı kolaylıklar yardımıyla yaygın olarak kullanılır ve tercih edilirler. Bentlı listeler, paradigma done strüktürsına misil ancak dizilere bakılırsa daha avantajlıdır.
Collaborate with us on GitHub The source for this C# IList Neden Kullanmalıyız content hayat be found on GitHub, where you hayat also create and review issues and pull requests. For more information, see our contributor guide.
If you're working within a single method (or even in a single class or assembly in some C# IList Kullanımı cases) and no one outside is going to see C# IList Nasıl Kullanılır what you're doing, use the fullness of a List. But if you're interacting with outside code, like when you're returning a list from a method, then you only want to declare the interface C# IList Nasıl Kullanılır without necessarily tying yourself to a specific implementation, especially if you have no control over who compiles against your code afterward.
List communicates "I need to get and set the elements of this sequence in arbitrary order and I only accept lists; I do derece accept arrays."
This will help if you decide to change the implementation of your class later to use a different concrete class. In that case the users of your library won't need to update their code since the interface doesn't change.
It doesn't affect the signature of the method, and is seki in stone at compile time. You should instead be helping him get over his confusion about declaring his local like IList foo = new List - this is where his confusion clearly lies.