locked
unsolved "System.NullReferenceException was unhandled " RRS feed

  • Question

  • 	public:
    		array<Image^> ^imageArray ;
    		array<String^>^ names;
    		array<int> ^CurrentImage;
    		
    		Form1(void)
    		{	System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
    			InitializeComponent();
    			Random ^Rnd = gcnew Random();
    			for(int r=0;r<16;r++)
    			CurrentImage[r]=Rnd->Next(101);
    the error is occured at the bold code.
    Saturday, April 16, 2011 10:05 AM

Answers

  • You have not instantiated the CurrentImage array.

    Typically you would do something like this - array<int>^ CurrentImage = gcnew array<int>(16);


    «_Superman_»
    Microsoft MVP (Visual C++)
    • Marked as answer by philip17 Saturday, April 16, 2011 10:43 AM
    Saturday, April 16, 2011 10:33 AM