C# IList Nerelerde Kullanılıyor Için 5-İkinci Trick

Wiki Article

"Are there any simple groups that appear bey zeros of the zeta function?" by Peter Freyd; why is this consternating to mathematicians?

Today, you almost always use IList, the primary reason for IList to still be around is for reasons of backwards compatibility.

Also, it casts IList to IList which has the potential to be dangerous. In most cases that I have seen, List which implements IList is used behind the scenes to implement IList, but this is hamiş guaranteed and hayat lead to brittle code.

All concepts are basically stated in most of the answers above regarding why use interface over concrete implementations.

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?

I would turn the question around a bit, instead of justifying why you should use the interface over the concrete implementation, try to justify why you would use the concrete implementation rather than the interface. If you kişi't justify it, C# IList Neden Kullanmalıyız use the interface.

Object kişi be a T too. Doing this will save you headache if you decide to use a Stack or C# IList Nedir some other veri structure further down the road. If all you need to do in the function is foreach through it, IEnumerable is C# IList Nedir really all you should be asking for.

If you specify your methods to return an interface that means you are free to change the exact implementation later on without the consuming C# IList Kullanımı method ever knowing.

If you are exposing your class through a library that others will use, you generally want to expose it via interfaces rather than concrete implementations.

tranmqtranmq 15.5k33 gold badges3232 silver badges2727 bronze badges 6 But in this case I güç't bind my collection to DataGridView rather I have to expose the _list member in MyCollection.

 

Less ridiculous way to prove that an Ascii character compares equal with itself in Coq more hot questions

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

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

Report this wiki page