c# to f# - How to convert between F# and C# tuples? -


i writing f# interop class used c#. thought f# had implicit conversion .net tuple<> type (similar ienumerable treated seq), wrote following code:

type myclass() =      member this.mymethod (t: tuple<int, int>) =         let meaningoflife (t : int * int) = 42         meaningoflife t 

this code fails compile following error: error fs0001: expression expected have type int * int here has type tuple

then how convert tuples between c# , f# (and back)?

if you're targeting .net 4.0 , above, don't need specify object tuple. f# tuples automatically compiled tuple. can use:

type myclass() =    member this.mymethod (t: int * int) =     let meaningoflife (t : int * int) = 42     meaningoflife t 

and should work fine c#.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -