首页 新闻 会员 周边

麻烦翻译下vs2010的代码段 “=>”

0
悬赏园豆:5 [已解决问题] 解决于 2013-11-15 10:19

没用过2010...对“=>”用法不是很了解,麻烦高手帮我翻译下一段代码,不胜感激

readFan = (index) => {
   if (index < 2) {
      return superIO.Fans[index];
   }

  else

  {
    // get GPIO 80-87
    byte? gpio = superIO.ReadGPIO(7);
    if (!gpio.HasValue)
      return null;

    // read the last 3 fans based on GPIO 83-85
    int[] masks = { 0x05, 0x03, 0x06 };
    return (((gpio.Value >> 3) & 0x07) ==
       masks[index - 2]) ? superIO.Fans[2] : null;
  }
};

  int fanIndex = 0;
  postUpdate = () => {
     // get GPIO 80-87
     byte? gpio = superIO.ReadGPIO(7);
     if (!gpio.HasValue)
        return;

     // prepare the GPIO 83-85 for the next update
     int[] masks = { 0x05, 0x03, 0x06 };
     superIO.WriteGPIO(7,
         (byte)((gpio.Value & 0xC7) | (masks[fanIndex] << 3)));
     fanIndex = (fanIndex + 1) % 3;
};

迷失路灯的主页 迷失路灯 | 初学一级 | 园豆:7
提问于:2013-08-29 15:39
< >
分享
最佳答案
0

Lambda 表达式”是一个匿名函数,它包含表达式和语句,并且可用于创建委托或表达式目录树类型。 所有 Lambda 表达式都使用 Lambda 运算符 (=>),该运算符读为“goes to”。该 Lambda 运算符的左边是输入参数(如果有),右边包含表达式或语句块。Lambda 表达式 x => x * x 读作“x goes to x times x”。

收获园豆:5
@珠@舒 | 菜鸟二级 |园豆:216 | 2013-08-29 16:05
其他回答(2)
0
Launcher | 园豆:45045 (高人七级) | 2013-08-29 15:43
0

呀?传说中的lambda表达式嘛?

W宁宁 | 园豆:522 (小虾三级) | 2013-08-29 15:49
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册