Reputation: 26658
I need a few public properties, in C# I will do this way.
public VendorOrderService { get; set; }
What is the shortest (correct/idiomatic) syntax for such properties in F#?
member val VendorService = Unchecked.defaultof<VendorOrderService> with get, set
P.S. I do understand that public properties are not super idiomatic for F#. But this code is working in larger .NET project, so such properties are obligatory.
Upvotes: 0
Views: 312
Reputation: 12883
First of all in C# you should write type, like this
public string VendorOrderService { get; set; }
In F# 3.0 you can use val keyword (just like you are):
type MyType() =
member val VendorOrderService = "" with get, set
or use [CLIMutable] attribute:
[<CLIMutable>]
type MyType = { VendorOrderService:string}
Upvotes: 5