-4

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

J. Doe
  • 47
  • 4
  • 3
    "some issues" is not a description of what problem you are having – khelwood Apr 08 '16 at 09:41
  • @khelwood, cheers mate, so helpful. The issues its having is that I cannot convert the array to a runnable C# format as I said in the question. – J. Doe Apr 08 '16 at 09:47
  • @GlenThomas thanks for your help, much better than the other guy – J. Doe Apr 08 '16 at 09:47
  • @J.Doe what the scope of your testdata? variable in a method? or a class' field? – Ian Apr 08 '16 at 09:49
  • 2
    J. , I guess @khelwood did not mean to be rude. People new to SO sometimes describe their problems as "does not work" or "having an issue" which does not leave much information for others to work on. – Fildor Apr 08 '16 at 11:13

1 Answers1

0

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[]
};
Ian
  • 30,182
  • 19
  • 69
  • 107