Hakkında herşey C# IList Nasıl Kullanılır

You cannot predict the future. Assuming that a property's type will always be beneficial birli a List is immediately limiting your ability to adapt to unforeseen expectations of your code.

From this it follows that your method implementation gönül represent its local variables however you wish. The implementation details are hamiş exposed. Leaving you free to change your code to something better without affecting the people calling your code.

lomaxxlomaxx 115k5858 gold badges146146 silver badges180180 bronze badges 1 Why would you return an IList in the first place? From a WCF service?

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.

Use whatever you want. It's your method. You're the only one who gets to see the internal implementation details of the method.

Architecture Astronauts. The chances you will ever write your own IList that adds anything to the ones already in the .Kemiksiz framework are so remote that it's theoretical jelly tots reserved for "best practices".

In case of using IList, the caller is always guareented things to work, and the implementer is free to change the underlying collection to any alternative concrete implementation of IList

If your methods form part of an interface, the methods will need to be defined using types available to that interface.

In most cases, if you are using a List and you think you could use a narrower interface instead - why hamiş 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.

API Entegrasyonu: Dış API'lerden tuzakınan verileri resmetmek ve yönetmek derunin kullanılabilir, bu da icraat arası bilgi ahzüitaini kolaylaştırır.

By asking for more C# IList Kullanımı than you need, you (1) make the caller do unnecessary work to satisfy your unnecessary demands, and (2) communicate falsehoods to the reader. Ask only for what you're going to use. That way if the caller katışıksız a sequence, they don't need to call ToList on it to satisfy your demand.

You C# IList Kullanımı might want to have an IOrderRepository that defines a collection of orders in either a IList or ICollection. You could then have different kinds of implementations C# IList Nerelerde Kullanılıyor to provide a list of orders bey long kakım they conform to "rules" defined by your IList or ICollection.

In particular, IList lets you use the C# IList Nedir indexer, and add/remove items; things that IEnumerable don't let you do.

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 C# IList Nerelerde Kullanılıyor foo = new List - this is where his confusion clearly lies.

Leave a Reply

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