array of array of array of struct - null reference

Reply Forum
Forum postqwazi1 @ 2011-11-17 02:42:45
ReplyReply to
Hi,
I have search long and far and tried many things and I cant seem to get this to work. I have a simplified example below.
All the examples I have found of jagged-arrays dont seem to go far enough for me.

struct MyRecord
{
public String Name;
public String Address;
public String Other;
}

MyRecord[][][] MyStruct = new MyRecord[255][][];


private void button1_Click(object sender, EventArgs e)
{
MyStruct[254][1][2].Address = "201";

}

The error i get is a NULLReferenceException unhandled. This is where I am finding it hard to pull together.
Any help will be appreciated.



Forum postqwazi1 @ 2011-11-17 15:34:53
ReplyReply to
in case anyone is ever looking for the same thing..

struct MyRecord
{
public String Name;
public String Address;
public String Other;
}

MyRecord[, ,] MyStruct = new MyRecord[255,255 ,255];

private void button1_Click(object sender, EventArgs e)
{
MyStruct[0,0,0].Name = "201";
textBox1.Text = MyStruct[0, 0, 0].Name;
}











© net-tutorials.com 2006 - 2012

MailContact net-tutorials.com