I'm trying to store all fields in an array and then multiply each field by * 3
public class Person
{
public int Field;
public int Field2;
}
var p = new Person {Field = 8};
int[] items = { ref p.Field, ref p.Field2 }; //this is not allowed
for (int i = 0; i < items.Length; i++)
{
ref int ret = ref items[i];
ret *= 3;
}
Expected p.Field
is 24
. Is it possible to do so? If not, is it possible to do it with properties instead of fields?