在VB.NET中重新编写F#代码 [英] Re-write F# code in VB.NET

查看:75
本文介绍了在VB.NET中重新编写F#代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前一段时间,我做了一些F#编程,以下代码用于序列化/反序列化float32数组: #light

Some time ago, I did some F# programming, the following code is used to serialize/deserialize float32 array: #light

但是,如今,我必须在VB.NET中进行一些编程才能再次对float32数组进行序列化/反序列化.由于F#编程不适合GUI,但是GUI对于我当前的编程是必需的. 我想知道如何在VB.NET中重写上面的代码. 例如,我有一个float32数组,(我不知道VB.NET中的哪种数据类型等效于F#中的float32数组)为(1.0,2.0,3.0);我想使用DataContractSerializer对其进行序列化,然后将其读回,这样我仍然可以获得相同的float32数组. 请分享您的代码. 感谢,并有一个愉快的一天! 约翰

However, nowadays, I have to do some programming in VB.NET to serialize/deserialize float32 array again. As F# programming is not suitable for GUI, but GUI is necessary for my current programming. I want to know how I can rewrite the above code in VB.NET. For example, I have a float32 array, (I don’t know what data type in VB.NET is equivalent to float32 array in F#) of (1.0, 2.0, 3.0); I want to serialize it using DataContractSerializer, then read it back so I can still get the same float32 array. Please share your code. Thanks and have a nice day! John

推荐答案

float32System.Single的别名(请参阅:

float32 is an alias for System.Single (see: http://msdn.microsoft.com/en-us/library/ee353708.aspx).

如果您可以通过使用WinForms设计器来获得价值,那么,是的,我同意VB.NET或C#是必经之路.但是您知道您可以从VB.NET项目中引用F#库吗?这意味着您可以在VB.NET中编写GUI并重用F#组件,而无需进行重写.

If you can gain value from using the WinForms designer then, yes, I'd agree VB.NET or C# would be the way to go. But did you know that you can reference F# libraries from VB.NET projects? That means you could write your GUI in VB.NET and reuse your F# components without the need for rewrites.

如果您要手工编写GUI,那么我不同意:F#非常适合编写手工编写的GUI(实际上,F#的async非常适合编写非阻塞GUI代码).

If you are going to hand-code your GUI, then I disagree: F# is perfectly good for writing hand-coded GUIs (indeed, F#'s async is excellent for writing non-blocking GUI code).

这篇关于在VB.NET中重新编写F#代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆