c# - 如何传递对函数的引用

标签 c# wpf visual-studio-2012

我将一些 VB 代码转换为 C#。现在我陷入了困境,我必须使用 ref 关键字传递参数。函数是

CurrentZone.Radius = ModSoftUniversal.perirad(ref  (Z2 - Z1), ref ( Xval - Xinc - CurrentZone.Centerx), ref ( dXval - CurrentZone.Centerx), ref ErrorFlag);

函数中的参数正在做一些计算,要将值传递给函数,必须使用 ref。 Visual Studio 显示以下 enter image description here .我需要帮助传递参数

最佳答案

您不能通过引用传递表达式。像这样添加临时变量:

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);

关于c# - 如何传递对函数的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37267883/

相关文章:

c# - WPF-- 同步动画

c# xamarin forms 主详细信息页面 MVVM

c# - 获取 TimeSpan 中的总小时数

visual-studio - 如何创建显示在 Web 类别中的 Visual Studio 项目模板?

windows-8 - windows 8模拟器怎么去锁屏?

c# - 为什么当我们以编程方式更改其文本时,TextBox 的 Text_Changed 事件不会触发?

wpf - "Busy"效果叠加

c# - 为Caliburn.Micro Action Message指定自定义防护属性

wpf - 如何使用文本 block 在 xaml 网格上设置可滚动条

visual-studio - Visual Studio 2012 - 获取最新文件并列出更改的文件?