没用过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;
};
呀?传说中的lambda表达式嘛?