I'm trying to figure out how to assign values to an array while a for
loop is happening. I've tried displaying one of the elements in the array but it always ends up with 0
using System;
namespace Assignment4
{
class Program
{
static void Main(string[] args)
{
int[] numArray = new int[48]; // 48 elements
int total = 1; // trying to get odd numbers to fill for the elements
int index;
for (index = 0; index <= numArray.Length; index++) // for loop to assign array
{
total = total + 2;
Console.WriteLine("#{0} current number is {1} ", index + 1, total); // double checking the index thing
}
Console.WriteLine(numArray[34]); // checking if the specified array will display the number in the list
}
}
}