CKTIS / C#
Enumerable.Select: practical reference
Enumerable.Select: practical reference: The deferred projection calls selector for each enumerated element and returns its result. The indexed overload passes a zero-based index.
Version: .NET LINQ; verified on .NET 10.0.14
Syntax
source.Select(/* overload-specific arguments */)The deferred projection calls selector for each enumerated element and returns its result. The indexed overload passes a zero-based index.
Use it to change element shape or type without mutating the source.
The selector runs again on every enumeration, so side effects can repeat.
An empty source yields an empty result. A null source or selector causes ArgumentNullException.
The complete program actually uses Enumerable.Select; its exact expected stdout is 1,4,9.
Examples
using System;
using System.Collections.Generic;
using System.Linq;
Console.WriteLine(string.Join(",", new[] { 1, 2, 3 }.Select(value => value * value)));
Result
1,4,9
The complete program actually uses `Enumerable.Select`; its exact expected stdout is `1,4,9`.