How can I return a dictionary from F # to C # without having to include FSharp.Core?

I am trying to return IDictionary<int,int>(created using dict tuplist) from F # to C #, but it says that I should include a link to FSharp.Coredue System.Collections.IStructuralEquatable.

I tried to return Dictionary<_,_>(dict tuplist), but it does not matter.

I even tried Dictionary<_,_>(dict tuplist, HashIdentity.Reference), but that says what intis structure ...

UPDATE

OK ME = STUPID

I simply did not want to include an important detail in my question: this is what I am returning my dictionary to F # entries and that is the problem. Since I added a record and a dictionary at the same time, and I saw IStructuralEquality, I just assumed that it was a dictionary that was a problem.

Doh! Unfortunately...

+3
source share
2 answers

I think this should work. If you are not showing any particular type of F # in a public signature, you do not need to reference the assembly FSharp.Core.dllin your C # project (you still need to distribute it using the F # library).

I tried to write a simple example, and I can compile a C # project without a link FSharp.Core. Could you try if the following project works for you: http://dl.dropbox.com/u/5676796/test.zip ?

It declares a simple F # module:

module Module1
open System.Collections.Generic

let getDictionary() = 
  let d = new Dictionary<_, _>()
  d.[10] <- 1
  d :> IDictionary<int, int>

And the code that references C # looks like this:

var d = Module1.getDictionary();
Console.WriteLine("d 10 = " + d[10]);

F #, F # ( , F # , F # ..).

+3

( , ...)

dict, F # - IDictionary, FSharp.Core. Dictionary , . , new Dictionary<_,_>(dict tupleList), , F # .NET Dictionary.

+2

Source: https://habr.com/ru/post/1741074/


All Articles