c++ - How do I check if System::Collections::ArrayList exists / is empty -
i'm trying access handle ::collections::arraylist 2 simple accessor/mutator functions:
/** -------------------------------------------- * public accessor rx message queue * --------------------------------------------- */ system::collections::arraylist^ peak_lib::rx_queue(void) { return this->m_queue_mes_rx; } /** -------------------------------------------- * public mutator rx message queue * --------------------------------------------- */ void peak_lib::rx_queue( system::collections::arraylist^ inlist ) { if ( inlist->count != 0 ) // <-- error line { this->m_queue_mes_rx = inlist; } }
my compiler throws an unhandled exception of type 'system.nullreferenceexception' occurred in my.exe
, adds reference not called on object ( or along these lines, have translate polish :/ ) when try access ->count
property ( see error line in code ) told me here check if inlist variable exists.
what's right (or @ least better :d) way check if arraylist
exists when i'm using c++/cli visual studio 2008?
initially, check null before checking count
if (inlist != nullptr) { if(inlist->count) {} }
Comments
Post a Comment