public virtual void Run(SimpleMemory memory) { var inputNumber = memory.ReadUInt32(Run_InputUInt32Index); // Or: inputNumber = new MemoryContainer(memory).GetInput(); // Arrays can be initialized as usual, as well as objects. var numberContainers1 = new[] { new NumberContainer { Number = inputNumber }, new NumberContainer { Number = inputNumber + 4 }, new NumberContainer { Number = 24 }, new NumberContainer(9) }; // Array elements can be accessed and modified as usual. numberContainers1[0].NumberPlusFive = inputNumber + 10; numberContainers1[1].IncreaseNumber(5); numberContainers1[2].IncreaseNumberBy10(); // Using ref and out. uint increaseBy = 10; numberContainers1[3].IncreaseNumberByParameterTimes10(ref increaseBy, out uint originalNumber);
public virtual void Run(SimpleMemory memory) { var inputNumber = memory.ReadUInt32(Run_InputUInt32Index); // Or: inputNumber = new MemoryContainer(memory).GetInput(); // Arrays can be initialized as usual, as well as objects. var numberContainers1 = new[] { new NumberContainer { Number = inputNumber }, new NumberContainer { Number = inputNumber + 4 }, new NumberContainer { Number = 24 }, new NumberContainer(9) }; // Array elements can be accessed and modified as usual. numberContainers1[0].NumberPlusFive = inputNumber + 10; numberContainers1[1].IncreaseNumber(5); // Note that array dimensions need to be defined compile-time. They needn't bee constants directly used // when instantiating the array but the size argument needs to be resolvable compile-time (so if it's a // variable then its value should be computable from all other values at compile-time). var numberContainers2 = new NumberContainer[1]; var numberContainer = new NumberContainer(); numberContainer.Number = 5; numberContainer.Number = numberContainer.NumberPlusFive; if (!numberContainer.WasIncreased) { numberContainer.IncreaseNumber(5); } numberContainers2[0] = numberContainer; for (int i = 0; i < numberContainers1.Length; i++) { numberContainers1[i].IncreaseNumber(numberContainers2[0].Number); } // You can also pass arrays and other objects around to other methods. memory.WriteUInt32(Run_OutputUInt32Index, SumNumberCointainers(numberContainers1)); }