Ne demek?

GetEnumerator metodu, bir sınıfa iterasyon strüktürlarını kazandıracak özellikleri barındıran IEnumerator nesnesi dönen bir metotdur.

The following example shows an implementation of the IEnumerator interface for a collection class of custom objects. The custom object is an instance of the type Box, and the collection class is BoxCollection. This code example is part of a larger example provided for the ICollection interface.

IEnumerator arayüzü, muta yapılarına umumi bir erişim yöntemi esenlayarak kodun henüz modüler olmasını ve hizmetının kolaylaşmasını katkısızlar. Başkaca, C# programlamada münteşir olarak kullanılan bu seçenek, kodun okunabilirliğini pozitifrır ve gene kullanılabilirliği isteklendirme değer.

Mevzuyu en basitiyle anlatmaya çtuzakıştım şayet anlaşılmayan bir gidiş var ise değerlendirme ile geçmiş dcivarüş esenlarsanız yada Soru-Yanıt sayfamızdan yazarsanız en hızlı şekilde yardımcı olmaya çkızılışırım.

Jon SkeetJon Skeet 1.5m881881 gold badges9.2k9.2k silver badges9.3k9.3k bronze badges 7 Thanks Jon for all ur help.I got it now and will study more to make it clear. Also I find following link very useful: stackoverflow.com/questions/558304/…

So all depends on what you mean saying "valid" state. If it's enclosed in usingdirrective, which is nothing else then try/finally, you have a guarantee that even if any exception happen in iteration the connection will be closed and

State of Iterators: Remember that IEnumerator holds state. If you share an enumerator between methods or threads, you might run into unexpected behavior.

Do you recognize those methods? It’s entirely possible you’ve never called them, even if you have been programming in C# for years. But you use this interface all the time. If you’ve ever used a foreach loop or called any C# IEnumerator neden kullanmalıyız LINQ methods, you’ve used the IEnumerator interface.

IEnumerable katışıksız just one method whereas IEnumerator has 2 methods (MoveNext and Reset) and a property Current. For C# IEnumerator Nasıl kullanılır easy understanding consider IEnumerable birli a box that contains IEnumerator inside it (though hamiş through inheritance or containment). See the code for better understanding:

WaitForSeconds fonksiyonuna ve null boy bos döndürmeye edebiyatın devamında detaylı gireceğim fakat şimdilik verdiğimiz saniye denli bekleme C# IEnumerator Nasıl kullanılır yaratmamızı sağlamış olduğunı bilmeniz kifayetli. 

To guarantee thread safety during enumeration, you sevimli either lock the collection during the entire enumeration or catch the exceptions C# IEnumerator Önemi Nedir resulting from changes made by other threads.

Mehrdad AfshariMehrdad Afshari 419k9292 gold badges857857 silver badges793793 bronze badges 6 4 The LINQy code actually returns an enumerator for the result of the Cast method, rather than an enumerator for the array...

To guarantee thread safety during enumeration, you birey lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement C# IEnumerator nerelerde kullanılıyor your own synchronization.

Bu soruya yalnızca kayıtlı kullanıcılar cevap yazabilirler. Yanıt yaymak yürekin lütfen giriş strüktürnız.

Leave a Reply

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