CKTIS / C#
filtering and transformations: odniesienie praktyczne
filtering and transformations: odniesienie praktyczne: Filtrowanie zachowuje wybrane elementy, a transformacja tworzy nowy kształt danych.
Wersja: C# language and .NET 10 reference runtime
Składnia
// filtering transformationsFiltrowanie zachowuje wybrane elementy, a transformacja tworzy nowy kształt danych.
Składaj Where i Select w czytelny potok, materializując tylko na potrzebnej granicy.
Selektory ze skutkami ubocznymi wykonują się przy każdej enumeracji.
Puste źródło daje pusty wynik, a wyjątek predykatu przerywa potok.
Kompletny program rzeczywiście używa filtering and transformations; oczekiwany stdout to dokładnie 4,6.
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;
var result = new[] { 1, 2, 3 }.Where(value => value > 1).Select(value => value * 2); Console.WriteLine(string.Join(",", result));
Wynik
4,6
Kompletny program rzeczywiście używa `filtering and transformations`; oczekiwany stdout to dokładnie `4,6`.