P
Progress City
Compiling the code below gives me the following error
"An object reference is required for the non-static field, method, or
property"
How do I create an object reference for the array "a"?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test
{
class Program
{
int[] a = { 2, 4, 6, 8 };
static void Main(string[] args)
{
for (int n = 0; n < 4; n++)
Console.WriteLine(a[n]);
Console.ReadKey();
}
}
}
"An object reference is required for the non-static field, method, or
property"
How do I create an object reference for the array "a"?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test
{
class Program
{
int[] a = { 2, 4, 6, 8 };
static void Main(string[] args)
{
for (int n = 0; n < 4; n++)
Console.WriteLine(a[n]);
Console.ReadKey();
}
}
}