blueLine
blueLine

Reputation: 1

Object Reference Not Set To Instance of an Object (XNA C#)

I have a quick question about a piece of code that I wrote:

for (int x = 0; x < width; x++)
{
    for (int y = 0; y < height; y++)
    {
            map.Add(main.Stone);
            Vector2 vec = new Vector2(x * 16, y * 16);
            pos.Add(vec);
    }
}

I get an error at pos.Add(vec); saying that the reference is null even though I declared it in the line above. I am pretty new to XNA so it's probably something really simple, but I can't seem to figure it out.

Upvotes: 0

Views: 720

Answers (2)

Nikhil Agrawal
Nikhil Agrawal

Reputation: 48568

pos is null.

vec cannot be null as it is declared above using value type entity (integers).

Check using debugger.

Upvotes: 1

egbrad
egbrad

Reputation: 2417

pos is the reference that is null, not vec. Where did you declare pos?

Upvotes: 0

Related Questions