M
mb
I have two .cs files and I am trying to have them interact in the project.
One is Form1.cs and the other is Define.cs
Form1 has code that creates a type "Cars"
I instantiate an array of type Test with properties
public static Cars[] myCar = new Cars[17];
public class Cars
{
public string Wheels;
...
}
Now, I have 17 cars that have specific properties like one has Cars.Wheels =
Chrome, etc.
However, I don't want to waste the space in my Form1.cs file, AND I may want
to use the 17 car's info in other programs. Therefore, I decided to make a
separate .cs file called Define to simply have the info for these cars.
However, when I try to call the Define file's constructor, it stops on the
first assignment line:
Cars[0].Wheels = "Chrome";
and says "Object reference not set to an instance of an object"
why is this. I feel that i have tried alll I can. I think I am missing
some understanding here. Could someone please help me?
One is Form1.cs and the other is Define.cs
Form1 has code that creates a type "Cars"
I instantiate an array of type Test with properties
public static Cars[] myCar = new Cars[17];
public class Cars
{
public string Wheels;
...
}
Now, I have 17 cars that have specific properties like one has Cars.Wheels =
Chrome, etc.
However, I don't want to waste the space in my Form1.cs file, AND I may want
to use the 17 car's info in other programs. Therefore, I decided to make a
separate .cs file called Define to simply have the info for these cars.
However, when I try to call the Define file's constructor, it stops on the
first assignment line:
Cars[0].Wheels = "Chrome";
and says "Object reference not set to an instance of an object"
why is this. I feel that i have tried alll I can. I think I am missing
some understanding here. Could someone please help me?