I have this code wrapper, being build as a dll.
namespace VoxelEditor
{
using namespace System;
public ref class name
{
private: VoxelEngine::test::name* _name;
public:
name()
{
_name = new VoxelEngine::test::name;
}
~name()
{
delete _name;
}
void test(IntPtr result, int a, int b)
{
_name->test((int*)result.ToPointer(), a, b);
}
};
}
namespace VoxelEngine
{
namespace test
{
void name::test(int*result, int a, int b)
{
*result = a + b;
}
}
}
I want to create this name class in c# and call the function test. I read it somewhere I should use IntPtr
int d = 0;
test.test(d, i, b);
Console.WriteLine(d);
question 1: It crashes, said that the "An exception of type 'SYstem.NullReferenceExeption' occured
question 2: What if a function returns a pointer? I have read this: https://msdn.microsoft.com/en-us/library/367eeye0.aspx And found some answers. But I don't get it. I am new on this.
dasref.