Açıklanan C# IList Nerelerde Kullanılıyor Hakkında 5 Kolay Gerçekler
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 ;)Same principle bey before, reversed. Offer the bare minimum that your caller requires. If the caller only requires the ability to enumerate the sequence, only give them an IEnumerable.
Edit: You do need to be quick to get answers in here. Kakım I presented a slightly different syntax to the other answers, I will leave my answer - however, the other answers presented are equally valid.
Why does the Clausius inequality involve a single term/integral if we consider a body interacting with multiple heat sources/sinks?
ToList first? How about returning it? I don't understand what you mean by "method will survive" when using vars? I know it will be a bit more work but won't you just have to change that to the new type birli well? So maybe IList to IList?
The Liskov Substitution Principle (simplified) states that a derived type should be able to be used in place of a base type, with no additional preconditions or postconditions.
class Kisi string ad; string soyad; public string Ad get return ad; grup ad = value; public string Soyad get return soyad; takım soyad = value;
In fact, any time you are using reflection IList is more convenient C# IList Kullanımı than IList-of-T, since generics and reflection don't play nicely together. It kişi be done, but it is a pain. Unfortunately since IList-of-T doesn't derive from C# IList Nerelerde Kullanılıyor IList there are cases where this güç yapan - but it is a good 95% rule.
the method, it emanet C# IList Nasıl Kullanılır make a huge difference -- if they have an array and you're asking for a list, they have to change the array to a list or C# IList Nerelerde Kullanılıyor v.v. whenever calling the method, a total waste of time C# IList Nasıl Kullanılır from both a programmer and performance POV.
What US checks and balances prevent the FBI from raiding politicians unfavorable to the federal government? more hot questions
By asking for more 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 has a sequence, they don't need to call ToList on it to satisfy your demand.
Şimdi beraber bir örnek yapalım. Bir hiç yönlü bağlamlı liste oluşturalım ve bu listeye kazara olarak eleman ekleyelim. Bu eklediğimiz elemanları da ekrana yazdıralım:
And, if you used a generic implementation, you would only be able to use a method that works for any object only with objects of a specific type.
If you had 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.