Reputation: 3652
i have one Managed C++ object
bool Test::TestStringNumber(String^ testData)
{
int len = testData->Length;
if(len > 0) return true;
}
am using same function in C#
void Main()
{
Test t = new Test()
t.TestStringNumber(null);
}
but application crash. during debugging i observed in C++ it comes as 'undefined value'
ALso i tried to test testData with nullptr in c++ code, and used following code, but still same crash
if( testData == nullptr && String::IsNullOrEmpty( testData ))
*One way is to catch exception in C++ managed code and return ;
Upvotes: 1
Views: 4872
Reputation: 4402
bool Test::TestStringNumber(String^ testData)
{
return !String::IsNullOrEmpty( testData );
}
Should work just fine? Not that I see the point in your code?
Upvotes: 6