Znalostná bázaCentrum skúšok
SKSlovenčina
Vybrať jazyk13

CKTIS / C#

System.Collections.Generic.IEnumerable: praktická referencia

System.Collections.Generic.IEnumerable: praktická referencia: IEnumerable<T> opisuje postupnosť bez záruky veľkosti, indexovania, ukladania do buffera alebo opakovateľnosti.

Verzia: .NET API; verified on .NET 10.0.14

Syntax

System.Collections.Generic.IEnumerable /* select a documented member or constructor */

IEnumerable opisuje postupnosť bez záruky veľkosti, indexovania, ukladania do buffera alebo opakovateľnosti.

Použite ho ako najmenší čítací kontrakt na postupné spracovanie prvkov.

Nová enumerácia môže zopakovať nákladnú prácu, priniesť iné údaje alebo byť pri jednorazovom zdroji nemožná.

Zdroj môže byť prázdny, nekonečný či jednorazový a chyby sa často objavia až pri MoveNext.

Úplný program skutočne používa System.Collections.Generic.IEnumerable; presne očakávaný stdout je 5.

Prí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;

IEnumerable<int> values = new[] { 2, 3 };
Console.WriteLine(values.Sum());

Výsledok

5

Úplný program skutočne používa `System.Collections.Generic.IEnumerable`; presne očakávaný stdout je `5`.

Zdroje