C# IList Nerelerde Kullanılıyor - Genel Bakış

I know there başmaklık been a lot of posts on this but it still confuses me why should you pass in an interface like IList and return an interface like IList back instead of the concrete list.

Arec BarrwinArec Barrwin 61.8k99 gold badges3030 silver badges2525 bronze badges 14 71 I have to disagree with your sardonic answer. I don't totally disagree with the sentiment of over-architecture being a real problem. However I think that especially in the case of collections that interfaces really shine.

Interface’ler karşı daha bir küme bilim yapmak isterseniz, dundaki kaynaklara nazar atabilirsiniz:

Dirilik a unique position be deduced if pieces are replaced by checkers (can see piece color but derece type)

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 as well? So maybe IList to IList?

Buraya özen etmenizi istiyorum. Liste tipine textbox dedik ve listeye textbox eklerken de direk nesne adını verdik. şu demek oluyor ki text özelliğini felan vermedik. Düver nesnenin kendisini verdik. Şimdi bu ustalıkin hoş yani şu;

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

In fact, any time you are using reflection IList is more convenient than IList-of-T, since generics and reflection don't play nicely together. It hayat be done, but it is a pain. Unfortunately since IList-of-T doesn't derive from IList there are cases where this dirilik özne - but it is a good 95% rule.

If you are exposing your class through a library that others C# IList Nerelerde Kullanılıyor will use, you generally want to expose it via interfaces rather than concrete implementations.

Collaborate with us on GitHub The source for this content dirilik be found on GitHub, where you birey also create and review issues and pull requests. For more information, see our contributor guide.

However, this makes the method more fragile, bey any change to the returned object C# IList Nerelerde Kullanılıyor type may break the calling code. In practice though, that generally isn't a major sorun.

I leave this up to show that if you needed to C# IList Nedir do it (e.g. the off chance a third party library returned a List that you needed to convert for another 3rd party library), you dirilik C# IList Nasıl Kullanılır do it this way.

for your return types. This gives your callers the most flexibility in passing in types to your methods and the most C# IList Kullanımı opportunities to cast/reuse the return values.

It doesn't affect the signature of the method, and is set in stone at compile time. You should instead be helping him get over his confusion about declaring his local like IList foo = new List - this is where his confusion clearly lies.

Leave a Reply

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