I need return integer values in c++ lib into c#. In c++ lib it return pointer, because I know, that in c++ we cannot return an array. I need that integer values to operate in c#
__declspec(dllexport) int* FindShortestPath(int from, int to)
{
//some algorithm...
return showShortestPathTo(used, p, to);
}
static int* showShortestPathTo(vector<bool> used, vector<int> p, int vertex)
{
vector<int> path;
//push to vector values
int* return_array = new int[path.size()];
//initialize array dynamically.....
return return_array;
}
The question is : what is the best way return values from c++ library into c#? What should I change?