Skip to content

F# interop - Passing Immutable Collections & F# Collections into F# Functions from C# #7833

Discussion options

You must be logged in to vote

they are returned as an FSharp variation (which is not a problem

This is not precise. The F# collection syntax provides F# collections. There are no limitations to use standard collections in F#.

Is there a way to pass in either the FSharp or Immutable variant? I know that I can just run ToList() on pass in, however I don't want to open the list up to possibly being mutated if it is already in an immutable format.

You can just declare the return type as F# collection. It will be seen as FSharp.Collections.List<T>. For immutability, you can use System.Collections.Immutable.ImmutableArray<T> and others.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@andrew-bauer-calibrated
Comment options

Answer selected by andrew-bauer-calibrated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants