事件和委托的F# [英] Events and Delegates in F#
本文介绍了事件和委托的F#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我没有在F#的经验,但在C#中的几行测试$ C $下我做了,我需要在F#改写了一个框架。
任何帮助将是AP preciated。
bar.Ready + =新Agent.ReadyHandler(bar_Ready);
静态无效bar_Ready(string信息)
{
Console.WriteLine(msg.body);
}
解决方案
我打了很多与此,这是C,它的工作$ C $。
bar.add_Ready(MSG乐趣 - > Console.WriteLine(MSG))
我不知道该怎么theoreticly纠正它,但它工作正常。
任何一个可以确认这是正确的吗?
I don’t have any experience in F# but have a few lines of test code in C# for a framework I've made that I need to rewrite in F#.
Any help would be appreciated.
bar.Ready += new Agent.ReadyHandler(bar_Ready);
static void bar_Ready(string msg)
{
Console.WriteLine(msg.body);
}
解决方案
I have played a lot with this and this is the code that work.
bar.add_Ready(fun msg -> Console.WriteLine(msg))
I don't know how theoreticly correct it is but it works fine.
Can any one confirm it is correct?
这篇关于事件和委托的F#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文