CKTIS / C#
System.Collections.Generic.IEnumerator: praktická reference
System.Collections.Generic.IEnumerator: praktická reference: IEnumerator<T> je stavový kurzor posouvaný metodou MoveNext, přičemž Current poskytuje prvek na platné pozici.
Verze: .NET API; verified on .NET 10.0.14
Syntaxe
System.Collections.Generic.IEnumerator /* select a documented member or constructor */IEnumerator je stavový kurzor posouvaný metodou MoveNext, přičemž Current poskytuje prvek na platné pozici.
Obvykle jej používejte přes foreach; při přímém použití vždy zajistěte volání Dispose.
Current nemá užitečný kontrakt před prvním úspěšným MoveNext ani po vrácení false.
Reset nemusí být podporován a změna podkladové kolekce enumerátor obvykle zneplatní.
Úplný program skutečně používá System.Collections.Generic.IEnumerator; přesně očekávaný stdout je 8.
Příklady
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
using IEnumerator<int> iterator = new List<int> { 8 }.GetEnumerator();
Console.WriteLine(iterator.MoveNext() ? iterator.Current : -1);
Výsledek
8
Úplný program skutečně používá `System.Collections.Generic.IEnumerator`; přesně očekávaný stdout je `8`.