2012-11-01 12 views

risposta

8

Il vincolo non annullabile su tipi è una caratteristica specifica F # e quindi fa non ha alcuna rappresentazione in .NET (e quindi C# non lo rispetta).

In realtà, si può risolvere questo anche in F # utilizzando un pericoloso Unchecked.defaultof<_> valore:

let trythis = new Wrapper(Unchecked.defaultof<_>) 

Questo è molto utile se si desidera controllare per null in un oggetto che è esposto al C#:

type Wrapper (value: test) = 
    if value = Unchecked.defaultof<_> then 
     invalidArg "value" "Value should not be null." 
    member val Value = value with get, set 
Problemi correlati