how to use c# struct from f#

2019-08-18 23:26发布

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?

标签: f# c#-to-f#
2条回答
女痞
2楼-- · 2019-08-19 00:10

Do you require something like that?

open System.Drawing
let point = Point(X = 1, Y = 3)
查看更多
贪生不怕死
3楼-- · 2019-08-19 00:11

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.
查看更多
登录 后发表回答