如何从f#使用c#结构 [英] how to use c# struct from f#

查看:77
本文介绍了如何从f#使用c#结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在f#中使用c#结构的语法是什么?如何分配字段值?



谢谢!



更新:



看起来像我可以声明变量本身可变,然后使用<-运算符设置它的字段...还有另一种方法吗?

解决方案

< blockquote>

看起来我可以声明变量
本身可变,然后使用<-运算符将其设置为
字段...
还有另一种方法吗? / p>

这是正确的做法。

  let mutable someStruct = CallSomething()
someStruct.Field1<-42
//等。


what's the syntax for using a c# struct in f#? how do i assign it's fields values?

thanks!

update:

looks like i can declare the variable itself mutable and then set it's fields using the <- operator...is there another way?

解决方案

looks like i can declare the variable itself mutable and then set it's fields using the <- operator...is there another way?

This is the correct thing to do.

let mutable someStruct = CallSomething()
someStruct.Field1 <- 42
// etc.

这篇关于如何从f#使用c#结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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