GREATEST KıLAVUZU C# ILIST KULLANıMı IçIN

Greatest Kılavuzu C# IList Kullanımı için

Greatest Kılavuzu C# IList Kullanımı için

Blog Article

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

Found this thread while I was looking for a solution to the exact sorun described in the original post. None of the answers met my situation entirely, however. Brody's answer was pretty close. Here is my situation and solution I found to it.

Bir dahaki sefere değerlendirme yaptığımda kullanılmak üzere aşamaı, elektronik posta adresimi ve web şehir adresimi bu tarayıcıya kaydet.

It's more nuanced than that. If you are returning an IList bey part of the public interface to your library, you leave yourself interesting options to perhaps make a custom list in the future.

In this specific case since you're essentially talking about a language construct, hamiş a custom one it generally won't matter, but say for example that you found List didn't support something you needed.

Örneğin, bayağıdaki kodda bir IAnimal tipinde bir parametre tanılamamladım ve bu bileğalışverişkene Dog ve Cat nesneleri atadım.

 

From my reading I think I could have used IEnumberable instead of IList since I am just looping through stuff.

Whether you return an Interface or a concrete type depends upon what you want to let your callers do with the object you created -- this is an API design decision, and there's no hard and fast rule. You have to weigh their ability to make full use of the object against their ability to easily use a portion C# IList Nasıl Kullanılır of the objects functionality (and of course whether you WANT them to be making full use of the object).

Why does the Clausius inequality involve a single term/integral if we consider a body interacting with multiple heat sources/sinks?

Adidaki şekilde Kisi isminde oluşturduğumuz derslikı oluşturduğumuz liste nesnesine ekleyelim.

rajeshrajesh C# IList Nasıl Kullanılır 39133 silver badges22 bronze badges 1 8 Excellent, clear answer, which I marked as helpful. However, I would add that for most developers, most of the time, the tiny difference C# IList Kullanımı in yetişek size and performance is C# IList Kullanımı not worth worrying about: if in doubt, just use a List.

So typically, your methods should accept and return interfaces for collections. This leaves your C# IList Nedir own implementation and your callers room to decide on the actual implementation bey required.

Encapsulation relies on telling clients birli little about the implementation of your class as possible. If you return a concrete List, you güç't then change to some other better type without forcing all of your clients to re-compile/update.

Report this page