5 Basit Teknikleri için C# IList Kullanımı

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 / veri-binding / etc ;)

Bu şekilde listelerin birbirini point etmesi ve bağlamlı listenin elemanlarına kıymet verilmesi esenlanmaktadır.

I think that, ideally, the .Safi Framework would include a static sorting method that accepts an IList, but the next best thing is to create your own extension method. It's not too hard to create a couple of methods that will allow you to sort an IList kakım you would a List.

Then click on the bulb symbol or place the cursor on the IList and press Strg + "." You will become several implementations offered, like:

swilliamsswilliams 48.6k2727 gold badges101101 silver badges130130 bronze badges 3 5 why derece 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

List is a specific implementation of IList, which is a container that güç be addressed the same way birli a linear array T[] using an integer index. When you specify IList kakım the type of the method's argument, you only specify that you need certain capabilities of the container. For example, the interface specification does hamiş enforce a specific data structure to be used.

I thought I'd never need to change from a List but had to later change to use a custom list library for the extra functionality it provided. Because I'd only returned an IList none of the people that used the library had to change their code.

 

but my problem is that i am not understanding C# IList Nedir what is its use and when to use it . So i hope that anyone emanet help me . Thanks .

It really comes down to the kind of functionality you need. I'd suggest using the List class in most cases. IList is best for when you need to make a custom array that could have some very specific rules that you'd C# IList Nerelerde Kullanılıyor like to encapsulate within a collection so you don't repeat yourself, but still want .Kupkuru to recognize it as a list.

If you're working within a single method (or even in a single class or assembly in some cases) and C# IList Nedir no one outside is going to see what you're doing, use the fullness of a List. But if you're interacting with outside C# IList Nedir code, like when you're returning a list from a method, then you only want to declare the interface 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 seki the elements of this C# IList Nasıl Kullanılır sequence in arbitrary order and I only accept lists; I do derece accept arrays."

If you use a concrete implementation of list, another implementation of the same list will derece be supported by your code.

It doesn't affect the signature of the method, and is grup 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.

Report this wiki page