I currently have the following code:
DecisionVariable[] attributes = { new DecisionVariable("Var1", 2), new DecisionVariable("Var2", 4), new DecisionVariable("Var3", 1), new DecisionVariable("Var4", 2), new DecisionVariable("Var5", 5), };
but I would like to create them using a For loop:
DecisionVariable[] attributes = { for (int i=0;i<49;i++) { new DecisionVariable ("Var" + i, iValues[i]); } };
In the second version, C # tells me that "For" has an invalid expression.
Do I have a typo somewhere or something like this is not allowed at all using the for loop in the constructor?
tmighty
source share