nv_data
doesn't exist because it is a variable local to the
start
method, and you are trying to access it in the
update
method.
That's like putting your mobile phone in the glove-box of your car, and expecting to find it when you open the glove-box in my car!
Local variables are just that: local to the method they are declare within, and are destroyed on exit from the method. The data that it referenced still exists (probably) however, since it is on the heap.
You may be able to solve this by moving the declaration of
nv_data
outside the method, to make it a class level variable:
private Data_struct [] nv_data;
void start()
{
But it sounds like you need to go back a few steps and re-read your course notes from the beginning - you seem to be trying to run before you can walk! :laugh:
"t's exactly this point that I think I'm lost.
When I use a constructor to create an object, I'm creating an instance. But concretely, what is it ? "
The problem is that this is pretty much fundamental: everything in C# is object based, which means that with very few exceptions everythign is instance based.
What is an instance? Ok...try this.
What colour is a car?
Answer: It doesn't have one. A car doesn't have a colour.
"This car" has a colour. "That car" has a colour. Your car; my car; his car; these all have a colour. But "A car" doesn't have a colour because not all cars are the same: some are red, some blue, some silver, ... You need to specify exactly which car you are talking about in order to refer to it Colour - which is just one of it's properties - the same applies to all the other properties such as engine size, number of doors, fuel consumption, fuel type, etc.
And that's important, because "car" is an abstract concept, and "this car", "that car", "your car", "my car", "his car" are examples of that abstract concept. You can drive a car, but you need a specific car in order to get down to the shops!
In computer terms, "car" is a class, and "this car" is an instance of the "car" class:
public class Car
{
public Color Color;
public int EngineSize;
public Car(Color color, int engineSize)
{
Color = color;
EngineSize = engineSize;
}
}
...
Car thisCar = new Car(Color.Red, 1600);
Car joesCar = new Car(Color.Blue, 5500);
Seriously, my friend: you need to get a book and follow it from beginning to end. You need to know this stuff, and loads of other bits - which you can't pick up on an ad-hoc basis. If you don't, you will just get more and more confused.