using System.Collections.Generic;
using System.Collections;
public static void Main()
List<(int, int)> myPairs = [(1, 2), (3, 4), (5, 6)];
Console.WriteLine($"The list [{string.Join(", ", myPairs)}]");
var secondThings = new ProjectedMutableList<(int, int), int>(myPairs, selector: x => x.Item2, modify: (pair, newYCoord) => (pair.Item1, newYCoord));
Console.WriteLine($"All the second items of each pair in the list: [{string.Join(", ", secondThings)}]");
Console.WriteLine($"All the second items of each pair in the list: [{string.Join(", ", secondThings)}]");
public class ProjectedMutableList<T, V>(List<T> things, Func<T, V> selector, Func<T, V, T> modify) : IList<V>
get { return selector(things[i]); }
set { things[i] = modify(things[i], value); }
public int IndexOf(V val) => things.FindIndex(x => Equals(selector(x), val));
public void RemoveAt(int index) => things.RemoveAt(index);
public int Count => things.Count;
public void Clear() => things.Clear();
public bool Contains(V val) => IndexOf(val) >= 0;
public IEnumerator<V> GetEnumerator() => things.Select(selector).GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public bool Remove(V val)
int index = IndexOf(val);
public bool IsReadOnly => false;
public void CopyTo(V[] dst, int index) => throw new NotSupportedException();
public void Insert(int index, V val) => throw new NotSupportedException();
public void Add(V val) => throw new NotSupportedException();