Convert between C # list and F # list

Note. This is a standalone documentation, but if you have other suggestions, or if I made any mistakes / missed something obvious, I would really appreciate your help.

Sources:

convert a common .NET list to an F # list

What can I do to pass a list from C # to F #?

https://msdn.microsoft.com/en-us/library/4kf43ys3(v=vs.110).aspx?cs-save-lang=1&cs-lang=fsharp#code-snippet-1


I am new to F # and C # and I want to convert a C # list to an F # list and vice versa. The code / commands for this change depending on where your code is (in C # or F #).

See my answer below. If you have any other suggestions, please let me know. Thank.

+4
source share
1

# ListModule.OfSeq .ToList(), :

// Currently inside a C# document
var CS_list = new List<int> {1,2,3}; 
var FS_list = ListModule.OfSeq(CS_List); // Microsoft.FSharp.Collections.ListModule
var CS_converted_back = FS_List.ToList();

F # Seq.toList ResizeArray<_>, :

// Currently inside an F# document
let FS_list = [1;2;3]
let CS_list = ResizeArray<int> FS_list // System.Collections.Generic.List
let FS_converted_back = Seq.toList CS_list

- , - , .

+5

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


All Articles