I have a CLR class library in c++:
namespace ANN_Lib {
public ref class ANN_FF_BP
{
private:
int neurons;
int inputs;
int outputs;
double **wi;
double *wl;
public:
ANN_FF_BP(int neurons, int inputs, int outputs);
void Train(double **p, double *t, int pairsCount, int epochs, double goal);
};
}
I am using this class as a reference in a WPF project:
ANN_FF_BP neuralNetwork = new ANN_FF_BP(neurons, inputs, outputs);
Now I want to call the Train() method (in WPF) from that class and pass in some arguments. I have a problem to pass the first two parameters (pointers) to the method. My current code in C#:
ANN_FF_BP neuralNetwork = new ANN_FF_BP(neurons, inputs, outputs);
double[,] P = new double[3, 2] { { 1, 2 }, { 3, 4 }, { 5, 6 } };
double[] T = new double[] { 2, 4, 6 };
neuralNetwork.Train(P, T, 3, 20, 0.01);
I get the following error in C#:

Can anybody explain me how to pass an C# array to a c++ class library method?
refC++/CLI class. Use .NET arrays in the class interface, which map to C#double[,]anddouble[]types:array<double, 2>andarray<double>msdn.microsoft.com/en-us/library/dtbydz1t.aspx functionx.com/cppcli/arrays/multidimension.htm Inside C++/CLI class, if you want to access native data, usepin_ptr