Düşünceler Hakkında Bilmek C# IList Nedir
Düşünceler Hakkında Bilmek C# IList Nedir
Blog 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 ;)
Same principle kakım before, reversed. Offer the bare minimal that your caller requires. If the caller only requires the ability to enumerate the sequence, only give them an IEnumerable.
Koleksiyonlar, verileri belirli bir düzende depolamak ve yönetmek karınin kullanılan bilgi bünyelarıdır. CollectionBase ile kendi koleksiyonlarınızı oluştururken, bu muta örgülarını elan aktif ve verimkâr bir şekilde kullanabilirsiniz.
That way you take advantage if you sevimli, while still allowing the client flexibility in what they pass in.
I tend to follow Jeffrey's advice for internal code, but for a public library, I would probably be more inclined to follow Eric's.
List is a specific implementation of IList, which is a container that sevimli be addressed the same way as 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 not enforce a specific veri structure to be used.
GitHub'da bizimle ortaklık bünyen Bu hapishaneğin kaynağı GitHub'da bulunabilir; burada ayrıca sorunları ve çekme isteklerini oluşturup gözden geçirebilirsiniz. Elan fazla fen sinein yardımda mevcut kılavuzumuzu inceleyin.
Ask those people what they'd like the methods to return. Your question is fundamentally "how do I know what software to write?" You know by getting to know what problems your customer özgü to solve, and writing code that solves their problems.
; being aware of the definition of the interface ie. all abstract methods that are there to be implemented by any class inheriting the interface. so if some one makes a huge class of his own with several methods besides the ones he inherited from the interface for some addition functionality, and those are of no use to you, its better to use a reference to a subclass (in this case the interface) and assign the concrete class object to it.
List implements those nene methods (derece including extension methods), on bütünüyle of that it has about 41 public methods, which weighs in your consideration of which one to use in your application.
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 C# IList Kullanımı public facing API, IList. Hopefully you get my C# IList Kullanımı point.
rajeshrajesh 39133 silver badges22 bronze badges 1 8 Excellent, clear answer, which I marked birli helpful. However, I would add C# IList Nasıl Kullanılır that for most developers, most of the time, the tiny difference in yetişek size and performance is not worth worrying about: if in doubt, just use a List.
When C# IList Nedir talking about return types, the more specific you are, the more flexible callers yaşama be with it.
If you had C# IList Kullanımı used IList in the rest of the app you could extend List with your own custom class and still be able to pass that around without refactoring.