由网友(没事别找我,有事更别找我)分享简介:是否有可能使用新的lambda EX pressions在Visual C ++ 2010的CLR事件处理程序?我试过下面的code:Is it possible to use the new lambda expressions in Visual C++ 2010 as CLR event handlers? I...
是否有可能使用新的lambda EX pressions在Visual C ++ 2010的CLR事件处理程序?我试过下面的code:
Is it possible to use the new lambda expressions in Visual C++ 2010 as CLR event handlers? I've tried the following code:
SomeEvent += gcnew EventHandler(
[] (Object^ sender, EventArgs^ e) {
// code here
}
);
这将导致以下错误信息:
It results in the following error message:
错误C3364:'系统::事件处理程序:无效的参数为代表的构造;委托目标必须是指向一个成员函数
error C3364: 'System::EventHandler' : invalid argument for delegate constructor; delegate target needs to be a pointer to a member function
我是不是与虎谋皮,或仅仅是我的语法错误?
Am I attempting the impossible, or is simply my syntax wrong?
推荐答案
没有可以做,在C ++ / CLI编译器没有得到更新,接受lambda语法。相当讽刺BTW给出的头开始,托管code了。
No can do, the C++/CLI compiler didn't get updated to accept the lambda syntax. Fairly ironic btw given the head-start that managed code had.
相关推荐
最新文章