我将一些VB代码转换为C#。现在我在这一点上卡住了,我必须使用ref关键字来传递参数。功能是如何将引用传递给函数
CurrentZone.Radius = ModSoftUniversal.perirad(ref (Z2 - Z1), ref (Xval - Xinc - CurrentZone.Centerx), ref (dXval - CurrentZone.Centerx), ref ErrorFlag);
函数中的参数都在做一些计算sott和将这些值传递给函数,REF必须被使用。 Visual Studio显示以下。我需要帮助传递参数
会是什么,甚至意味着按引用传递的*结果*计算的? (此外,请将代码*作为文本发布*而不是屏幕截图 - 然后您可以将错误消息发布为更多文本。) –
声明变量,不要将计算作为参数进行,因为它是参考参数,它需要存储位置值。恩。 int minusZ = Z2-Z1;然后改变做ref minusZ而不是(Z2 - Z1)。 –
几个类似的链接: http://stackoverflow.com/questions/24828842/a-ref-or-out-argument-must-be-an-assignable-variable http://stackoverflow.com/questions/7307705/help-fixing-errors-in-c-sharp-a-ref-or-out-argument-must-be-an-assignable http://stackoverflow.com/questions/2165892/passing-an-explicit-cast -as-a-ref-parameter-c –