hello, guys:
this is the code:
// created on 5.7.2002 at 10:47
using System;
public class Test
{
public struct Car
{
public int year;
}
Car mycar = new Car();
public static void Main()
{
Console.WriteLine(mycar.year);
}
public void mytest()
{
Console.WriteLine(mycar.year);
}
}
and I got such error: An object reference is required for the nonstatic field, method, or property 'Test.mycar'
So I have to declare another Car mycar = new Car();
in static void Main() function to solve this problem,
so is there any way so that I declare Car mycar = new Car();
once and use it in both functions: void main() and void mytest().
Thank you!!