All,
I am currently trying to convert some lines of code from Java to C# using Visual Studio 2013. However the lines below is causing me some issues:
final double testdata[][] = {{patientTemperatureDouble, heartRateDouble, coughInteger, skinInteger}};
result[i] = BayesClassifier.CalculateProbability{testdata[k],category[i]};
Any clarification as to converting the array to a suitable c# format would be greatly appreciated, I have attempted using readonly and sealed but I've had no luck.
Thanks
As asked in the comment, if your testdata
is a class' field, you could use readonly
keyword. But if it is a local variable/method parameter, there is no direct equivalent in C#. In either case, given a set of double[]
, you can initialize a double[][]
jagged array by removing one of the curly brackets:
readonly double[][] testdata = new double[][] { //for class field
patientTemperatureDouble, //is double[]
heartRateDouble, //is double[]
coughInteger, //is double[]
skinInteger //is double[]
};
double[][] testdata = new double[][] { //for local variable
patientTemperatureDouble, //is double[]
heartRateDouble, //is double[]
coughInteger, //is double[]
skinInteger //is double[]
};