Stuck with structs

Apr 22 2007 9:02 AM

I've got one line (so far) in my program that doesn't want to play ball...

[code]system[mapLocation[random, random2]].AdjSystem[planetAdderLoop] = subSystemNumber;[/code]

these come from:

[code]struct SystemStruct
{
    ...
    private int[] adjSystems;
    public int[] AdjSystems;
    {
        get
        {
            return adjSystems;
        }
        set
        {
            adjSystems = value;
        }
    }
    ...
}[/code]

[code]SystemStruct[] system = new SystemStruct[650];[/code]

and

[code]int subSystemNumber = new int();[/code]

Now, I've seen this at [url]http://www.c-sharpcorner.com/UploadFile/rajeshvs/StructuresInCS11112005234341PM/StructuresInCS.aspx[/url]

[code]//C#: Property
// Author: [email protected]
using  System;
class MyStruct
    private int x;
    public int X
    {
        get
        {
            return x;
        }
        set
        {
            x = value;
        }
    }
}
class MyClient
    public static void Main()
    {
        MyStruct ms = new MyStruct();
        ms.X = 10;
        int xVal = ms.X;
        Console.WriteLine(xVal);//Displays 10
    }
}
[/code]

Is it the fact I'm arraying the variable I'm trying to use here?  What do I do to change that system[x].AdjSystems[y] so that 'Object reference not set to an instance of an object.' stops screaming at me?


Answers (1)