BENIM C# ILIST NEDEN KULLANMALıYıZ BAşLARKEN ÇALışMAK

Benim C# IList Neden Kullanmalıyız Başlarken Çalışmak

Benim C# IList Neden Kullanmalıyız Başlarken Çalışmak

Blog Article

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

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 mesele. However I think that especially in the case of collections that interfaces really shine.

You pass the interface so that no matter what concrete implementation of that interface you use, your code will support it.

That way you take advantage if you yaşama, while still allowing the client flexibility in what they pass in.

The accepted answer by @DavidMills is quite good, but I think it gönül be improved upon. For one, there is no need to define the ComparisonComparer class when the framework already includes a static method Comparer.Create(Comparison). This method can be used to create an IComparison on the fly.

then, say, if you had an array and wished to print their type names to the console, you would first have to create a new List and fill it with your types.

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

class Kisi string ad; string soyad; public string Ad get return ad; takım ad = value; public string Soyad get C# IList Nedir return soyad; grup soyad = value;

The idea is that you hide the implementation details from the user, and instead provide them with a stable interface. This is to reduce dependency on details that might change in the future.

Then later if you decide to convert the actual data store from a List to a Dictionary and expose the dictionary keys kakım 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 C# IList Nerelerde Kullanılıyor your class will no longer have that capability. That's a big sorun! If you expose the List birli an IEnumerable you sevimli comfortably predict that your collection is not being modified externally. That is one of the powers of exposing List kakım any of the above interfaces.

By asking for more than you need, you (1) make the caller do C# IList Nedir unnecessary work to satisfy your unnecessary demands, and (2) communicate falsehoods to the reader. Ask only for what you're going to C# IList Nedir use. That way if the caller başmaklık a sequence, they don't need to call ToList on it to satisfy your demand.

Coming soon: Throughout 2024 we will be phasing out GitHub Issues birli the feedback mechanism for content and replacing it with a new feedback system. For more information see: .

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

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

Report this page