Each, , IEnumerable<T>. , , ref:
public static class ExtensionMethods
{
public delegate void RefAction<T>(ref T arg);
public static void Each<T>(this T[] array, RefAction<T> action)
{
for(int i = 0; i < array.Length; i++)
{
action(ref array[i]);
}
}
}
...
new []
{
InstanceOfProperty,
InstanceOfProperty,
InstanceOfProperty ...
}.Each((ref Property p) => p.Dimensions.Height = 100.0);
, Dimension , ( ). - :
new []
{
InstanceOfProperty,
InstanceOfProperty,
InstanceOfProperty ...
}.Each((ref Property p) => p.Dimensions = new Dimension
{
Width = p.Dimensions.Width,
Height = 100.0
});
, , , ...