C# ILIST NEDIR IçIN ADıM HARITAYA GöRE YENI ADıM

C# IList Nedir Için Adım Haritaya göre Yeni Adım

C# IList Nedir Için Adım Haritaya göre Yeni Adım

Blog Article

The above is an IList itself kakım this is what seems to be the standard to use with nhibernate. Otherwise I might have returned IEnumberable back but not sure. Still, I emanet't figure out what the user would 100% need(that's where returning a concrete saf an advantage over).

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.

Koleksiyonlar, verileri sınırlı bir düzende depolamak ve yönetmek bâtınin kullanılan muta gestaltlarıdır. CollectionBase ile kendi koleksiyonlarınızı oluştururken, bu data örgülarını daha etkin ve rantabl bir şekilde kullanabilirsiniz.

Your functions above only care about being able to iterate over a list. Ideally they shouldn't need to know who implements that list or how they implement it.

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

In some code this birey be quite important and using concrete classes communicates your intent, your need for that specific class. An interface on the other hand says "I just need to call this takım of methods, no other contract implied."

StuartLCStuartLC 106k1818 gold badges216216 silver badges289289 bronze badges Add a comment  

3 @phoog: Considering where Eric is coming from, it wouldn't be surprising he is more cautious about breaking changes. But it is definitely a valid point.

One Piece Şeytan Meyveleri Kitabı ile anime tasarlarımıza devam edelim. Önceleri toparladığım bir makaleydı bu yazı. Bir anime izlerken o animeyi ne derece çok sevdiğime…

Then later if you decide to convert the actual data store from a C# IList Neden Kullanmalıyız List to a Dictionary and expose the C# IList Neden Kullanmalıyız dictionary keys bey the actual value for the property (I have had to do exactly this before). Then consumers who have come to expect that their changes will be reflected inside of your class will no longer have that capability. C# IList Kullanımı That's a big mesele! If you expose the List as an IEnumerable you kişi comfortably predict that your collection is not being modified externally. That is one of the powers of exposing List as any of the C# IList Nedir above interfaces.

kemiller2002kemiller2002 115k2828 gold badges198198 silver badges253253 bronze badges Add a comment  

Benefit of using an Interface is that you get to implement your functionality or better yet, C# IList Neden Kullanmalıyız the only functionality you require. So, if iteration/enumeration is required only, then there is no need for the Sort, Add methods.

This will help if you decide to change the implementation of your class later to use a different concrete class. In that case the users of your library won't need to update their code since the interface doesn't change.

So I have been playing around with some of my methods on how to do this. I am still not sure about the return type(if I should make it more concrete or an interface).

Report this page