Question:
Declaring an array in C#?
Brutalmouse
2012-04-30 19:25:30 UTC
I need to assign this array in C# with particular values, so I can carry out commands with it:
valueArray
[0]
[1] 10
[2] 12
[3] 14
[4] 16
[5] 18
[6] 19
[7] 21
[8]

It may help to know that this syntax outputs a value of "x=512" given the array (all variables are int type):
x=0;
for (i=1; i<=3; i++)
x+=valueArray[i]*valueArray[i+1];
Console.WriteLine("x = {0}",x);

That is because it uses the values in the aforementioned array to compute a total. I'm really in need of the code I would use to assign this array. Help!
Three answers:
Ratchetr
2012-04-30 19:38:35 UTC
int[] valueArray = { 0, 10, 12, 14, 16, 18, 19, 21, 0 };
gornick
2017-03-03 13:31:52 UTC
thank you for posting your homework challenge on Yahoo! solutions. To get an respond on your question, you will could submit your proposed selection (the code you're starting to be written as a consequence a ways), and ask the team to help you identify why it does not paintings. in case you have now no longer written any code so a ways, now could nicely be a outstanding time to try this. Please evaluate unfastened to placed up suited right here as quickly as greater in case you have a query to invite, on the different hand than a homework identify with a ? Appended to the best. thank you for employing Yahoo! ideas.
Fadi
2012-04-30 19:33:46 UTC
int[] listOfIntegers = new int[10];

change number 10 to whatever size you want your array to be


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...