C# IList Neden Kullanmalıyız Seçenekler

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 ;)

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

Interface’ler üzerine daha bir araba bilim edinmek isterseniz, aşağıdaki kaynaklara basar atabilirsiniz:

If you think that interfaces are useful only for building over-sized, grandiose architectures and have no place in small shops, then I hope that the person sitting across from you in the interview isn't me.

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

I would turn the question around a bit, instead of justifying why you should use the interface over the concrete implementation, try to justify why you would use the concrete implementation rather than the interface. If you emanet't justify it, use the interface.

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

class Kisi string ad; C# IList Nerelerde Kullanılıyor string C# IList Nedir soyad; public string Ad get return ad; takım ad = value; public string Soyad get return soyad; seki soyad = value;

In most cases, if C# IList Neden Kullanmalıyız you are using a List and you think you could use a narrower interface instead - C# IList Neden Kullanmalıyız why C# IList Nasıl Kullanılır not IEnumerable? This is often a better fit if you don't need to add items. If you need to add to the collection, use the concrete type, List.

If you can consider your method, determine that you probably won't be changing the return collection type, then 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 more general.

Obviously if you are being asked which you use in an interview, you say IList, smile, and both look pleased at yourselves for being so clever. Or for a public facing API, IList. Hopefully you get my point.

The most important case for using interfaces over implementations is in the parameters to your API. If your API takes a List parameter, then anyone who uses it katışıksız to use List.

Özel koleksiyonlar oluşturmanıza imkân tanılamar: ölçünlü derme sınıfları ihtiyaçlarınızı önlamıyorsa, kendi özel koleksiyonlarınızı C# CollectionBase kullanarak oluşturabilirsiniz. Bu, muta binalarınızı istediğiniz şekilde özelleştirmenizi sağlar.

Encapsulation relies on telling clients bey little about the implementation of your class as possible. If you return a concrete List, you can'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 *