CKTIS / C#
filtering and transformations: riferimento pratico
filtering and transformations: riferimento pratico: Il filtro conserva gli elementi scelti, mentre la trasformazione crea una nuova forma dei dati.
Versione: C# language and .NET 10 reference runtime
Sintassi
// filtering transformationsIl filtro conserva gli elementi scelti, mentre la trasformazione crea una nuova forma dei dati.
Componi Where e Select in una pipeline leggibile e materializza solo al confine necessario.
I selettori con effetti collaterali si eseguono a ogni enumerazione.
Una sorgente vuota dà un risultato vuoto e un’eccezione del predicato ferma la pipeline.
Il programma completo usa realmente filtering and transformations; lo stdout esatto atteso è 4,6.
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;
var result = new[] { 1, 2, 3 }.Where(value => value > 1).Select(value => value * 2); Console.WriteLine(string.Join(",", result));
Risultato
4,6
Il programma completo usa realmente `filtering and transformations`; lo stdout esatto atteso è `4,6`.