Create an object in C# from an F# object with optional arguments

Posted by Mark Pearl on Stack Overflow See other posts from Stack Overflow or by Mark Pearl
Published on 2010-05-01T14:49:23Z Indexed on 2010/05/01 14:57 UTC
Read the original article Hit count: 304

Filed under:
|
|

I have a object in F# as follows...

type Person(?name : string) = 
    let name = defaultArg name ""
    member x.Name = name

I want to be able to create an instance of this object in a C# project. I have added as a reference the correct libraries to the project and can see the object via intellisense however I am not sure on the correct syntaxt to create an instance of the object.

Currently I have the following in my C# project - which the compiler doesn't like...

var myObj1 = new Person("mark");            

© Stack Overflow or respective owner

Related posts about F#

Related posts about c#