Converting between C# List and F# List -
remark: self-documentation, if have other suggestions, or if made mistakes/miss out obvious, appreciate help.
sources:
convert .net generic list f# list
i beginner in f# , c#, , want convert c# list f# list, , vice versa. code/commands doing changes depending on code (in c# or f#).
please see answer below. if have other suggestions, please let me know. thank you.
inside c# document, can use listmodule.ofseq
, .tolist()
, this:
// inside 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();
inside f# document, can use seq.tolist
, resizearray<_>
, this:
// inside 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
if made mistakes, or if miss out obvious, please let me know.
Comments
Post a Comment