Mono : is there a System.Tuple?

2019-02-22 02:07发布

I am trying to do some interop between C# and F# in Mono. Is there a System.Tuple in Mono C#? I can see the one in Mono.CSharp, but that doesn't seem to be the same type as F# (a' * b'). So,

(a) Is there a System.Tuple in Mono C# or (b) Is there a cast between tuples in Mono C# and F#?

3条回答
家丑人穷心不美
2楼-- · 2019-02-22 02:45

I just tried

System.Tuple<int, int> t2 = new System.Tuple<int, int>(1, 2); 

and it worked, on version 4.0

查看更多
该账号已被封号
3楼-- · 2019-02-22 02:57

Yes Mono supports a Tuple type. I know it's in 4.0 but I've seen comments of it's availability since version 2.6.

查看更多
Rolldiameter
4楼-- · 2019-02-22 03:07

It also depends on what version of F# compiler do you use. If you compile your F# code using F# compiler for .NET 2.0, then it will use FSharp.Core.dll for .NET 2.0, which contains the declaration of Tuple<..> classes. Then you can simply reference FSharp.Core.dll from your C# project and you'll find tuple there (It is in the System namespace to make it compatible with .NET 4)

I believe that the ZIP release from Microsoft and the F# packages both contain 2.0 version. I'm not sure about the version of F# bundled with Mono 2.10 though or the one in Debian.

查看更多
登录 后发表回答