I have a program I did in Java and I'm trying to do it in C#. Visual Studio is flagging a lot at the bottom. Where I declare and define the method at the bottom. I want my method to receive the numbers array and then multiply each element by 2 and then send that result back into the main program.
But I almost think I got the code in the wrong spot, I don't know.
But I almost think I got the code in the wrong spot, I don't know.
C#:
private void buttonShowModifiedValues_Click(object sender, EventArgs e)
{
int[] numbers = { 2, 4, 5, 6, 8 };
int[] newArray;
newArray = modifyNumbers(numbers);
}
private void FormPassArrayToMethod_Load(object sender, EventArgs e)
{
int[] numbers = { 2, 4, 5, 6, 8 };
for (int i = 0; i < numbers.Length; i++)
textBoxOriginalArrayValues.Text = textBoxOriginalArrayValues.Text + numbers[i] + " ";
}
public static int[] modifyNumbers(int[] modifiedNumbers)
for(int i = 0; i<modifiedNumbers.Length; i++)
modifiedNumbers[i] *= 2;
return modifiedNumbers;