public struct MY_TYPE1
        {
            public int A;
            public int B;

        }

        public class MY_TYPE2
        {
            public int X;
            public int Y;

            public MY_TYPE1[] array2 = new  MY_TYPE1[80];           
        }
 MY_TYPE2[] array1= new MY_TYPE2[800];

public void MtMethod()
{
       [B]  array1[0].array2[0].A=0;[/B]
}

When i try to use this code ,a null reference exception was unhandled.

the bold written row gives the exception "the object reference not set to an instance object" .

how can i escape from this exception?
where and how can i initalize array1[]?

Hello, in your case you should at first initalize array1[0], and the access it variable 'array2[0]'.

array1[0] = new MY_TYPE2();

I think your MY_TYPE2 class needs a constructor where your struct array can be initialized. For the moment it has no constructor so a default constructor is called :

MY_TYPE2()
{
}

This does not initialize your struct array as far as I can see.

Hello, in your case you should at first initalize array1[0], and the access it variable 'array2[0]'.

array1[0] = new MY_TYPE2();

thanks for helps.
array1[0] = new MY_TYPE2();

this code solve my problem.

This question has already been answered. Start a new discussion instead.