Array of structures CLI

Posted by Nitroglycerin on Stack Overflow See other posts from Stack Overflow or by Nitroglycerin
Published on 2010-04-06T10:12:34Z Indexed on 2010/04/06 10:43 UTC
Read the original article Hit count: 355

Filed under:
|
|
|
public value struct ListOfWindows
{
 HWND hWindow;
 int winID;
 String^ capName;
};

thats my structure now i have created an array of them:

array<ListOfWindows ^> ^ MyArray =  gcnew array<ListOfWindows ^>(5);

now to test if that works i made a simple function:

void AddStruct( )
{
  HWND temp = ::FindWindow( NULL, "Test" );
  if( temp == NULL ) return;
  MyArray[0]->hWindow = temp; // debug time error..

  return;
}

ERROR: An unhandled exception of type 'System.NullReferenceException' occurred in Window.exe

Additional information: Object reference not set to an instance of an object.

dont know what to do.. kinda new to CLI so if you can help please do.. Thanks.

© Stack Overflow or respective owner

Related posts about cli

Related posts about struct