I have made an extension method for initializing arrays of ValueTuples, and realized that it can be done in two different ways. I can either replace the array elements with new tuples, or change the properties of the existing elements (because ValueTuple<T1, T2>
structs are mutable). I wonder if there is any practical difference between using the one method or the other. Here are the candidates:
public static void Initialize1<T1, T2>(this ValueTuple<T1, T2>[] array,
T1 item1, T2 item2)
{
for (int i = 0; i < array.Length; i++)
{
array[i] = (item1, item2);
}
}
public static void Initialize2<T1, T2>(this ValueTuple<T1, T2>[] array,
T1 item1, T2 item2)
{
for (int i = 0; i < array.Length; i++)
{
array[i].Item1 = item1;
array[i].Item2 = item2;
}
}