Baza wiedzyCentrum egzaminacyjne
PLPolski
Wybierz język13

CKTIS / C#

System.Collections.Generic.IEnumerable: odniesienie praktyczne

System.Collections.Generic.IEnumerable: odniesienie praktyczne: IEnumerable<T> opisuje sekwencję bez gwarancji rozmiaru, indeksowania lub buforowania.

Wersja: .NET API; verified on .NET 10.0.14

Składnia

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

IEnumerable opisuje sekwencję bez gwarancji rozmiaru, indeksowania lub buforowania.

Stosuj jako minimalny kontrakt odczytu kolejnych elementów.

Powtórna enumeracja może ponownie wykonać kosztowną pracę albo dać inne dane.

Źródło może być puste, nieskończone lub jednorazowe; wyjątki pojawiają się często dopiero w MoveNext.

Kompletny program rzeczywiście używa System.Collections.Generic.IEnumerable; oczekiwany stdout to dokładnie 5.

Przykłady

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());

Wynik

5

Kompletny program rzeczywiście używa `System.Collections.Generic.IEnumerable`; oczekiwany stdout to dokładnie `5`.

Źródła