문제

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.

도움이 되었습니까?

해결책 2

type Foo() =
     member val Text : string = null with get, set

다른 팁

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}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top