CKTIS / C#
System.Collections.Generic.IEnumerator: riferimento pratico
System.Collections.Generic.IEnumerator: riferimento pratico: IEnumerator<T> è un cursore con stato avanzato da MoveNext, mentre Current espone l’elemento nella posizione valida.
Versione: .NET API; verified on .NET 10.0.14
Sintassi
System.Collections.Generic.IEnumerator /* select a documented member or constructor */IEnumerator è un cursore con stato avanzato da MoveNext, mentre Current espone l’elemento nella posizione valida.
Normalmente usalo tramite foreach; nell’uso diretto assicurati sempre di chiamare Dispose.
Current non ha un contratto utile prima del primo MoveNext riuscito o dopo che MoveNext restituisce false.
Reset può non essere supportato e modificare la raccolta sottostante solitamente invalida l’enumeratore.
Il programma completo usa realmente System.Collections.Generic.IEnumerator; lo stdout esatto atteso è 8.
Esempi
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);
Risultato
8
Il programma completo usa realmente `System.Collections.Generic.IEnumerator`; lo stdout esatto atteso è `8`.