I converted some VB Code to C# . Now I am stuck up at this point where I have to pass the parameters using ref keyword. The function is
CurrentZone.Radius = ModSoftUniversal.perirad(ref (Z2 - Z1), ref ( Xval - Xinc - CurrentZone.Centerx), ref ( dXval - CurrentZone.Centerx), ref ErrorFlag);
The parameters in the function are doing some sott of calculation and to pass the values to the function , ref has to be used.
Visual Studio shows the following
. I need help in passing the parameters
You can't pass expression by reference. Add temporary variable like this:
var z = Z2 - Z1;
var x1 = Xval - Xinc - CurrentZone.Centerx;
var x2 = dXval - CurrentZone.Centerx;
CurrentZone.Radius = ModSoftUniversal.perirad(ref z, ref x1, ref x2, ref ErrorFlag);
Make the code like this
var z1z2Result = (Z2 - Z1);
var xValxIncres = (Xval - Xinc - CurrentZone.Centerx);
var dxValResult = (dXval - CurrentZone.Centerx);
ModSoftUniversal.perirad(ref z1z2Result, ref xValxIncres, ref dxValResult, ref ErrorFlag);
The reason is you can't make something byreference if it isn't assigned to a variable it can reference itself to
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With