I am wondering how I could make a calculation (in this case, calculating the average) with a variable number of variables / fields in C#? I could write an if case for each number of variables but I bet there is a better way for it, right? The bad way would like this:
if (numberOfFields == 4)
(field1 + field2 + field3 + field4) / 4;
if (numberOfFields == 5)
(field1 + field2 + field3 + field4 + field5) / 5;
.
.
.
Greetings!