Когда выполняется запрос linq - C#
Формулировка задачи:
int[] msv = { 1, 2, 3 };
var res = msv.Select(n => n * n).ToArray();
foreach (int i in res) Console.WriteLine(i); // 1, 4, 9
msv[2] = 10;
foreach (int i in res) Console.WriteLine(i); // 1, 4, 9Решение задачи: «Когда выполняется запрос linq»
textual
Листинг программы
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
public static void Main()
{
int[] msv = { 1, 2, 3 };
IEnumerable<int> query = msv.Select(n => n * n);
Console.WriteLine(String.Join(", ", query));
msv[2] = 10;
Console.WriteLine(String.Join(", ", query));
}
}