It is interop between C# and F#
In F#,
type test =
{
value: int
}
type Wrapper (value: test) =
member val Value = value with get, set
let trythis = new Wrapper(null) // error as expected
However, in C#
var trythis = new Wrapper(null); //this runs fine
Hepatitis C is a liver infection caused by the hepatitis C virus (HCV). Hepatitis C is spread through contact with blood from an infected person. Today, most people become infected with the hepatitis C virus by sharing needles or other equipment used to prepare and inject drugs.
Overview. Hepatitis C virus (HCV) causes both acute and chronic infection. Acute HCV infections are usually asymptomatic and most do not lead to a life-threatening disease. Around 30% (15–45%) of infected persons spontaneously clear the virus within 6 months of infection without any treatment.
Many people with chronic HCV suffer from aches and pains in their joints. A variety of different joints can be involved but the most common are in the hands and wrists. These pains are often minor but occasionally the pain can be quite severe. In such cases painkillers can be used to relieve the symptoms.
Treatment for hepatitis C keeps changing quickly. The standard treatment was typically interferon along with other drugs -- usually ribavirin and either boceprevir (Victrelis) or telaprevir (Incivek). But many people have a hard time with interferon's side effects, which include fatigue, fever, chills, and depression.
The non-nullable constraint on types is an F# specific feature and so it does not have any representation in .NET (and therefore C# does not respect it).
In fact, you can workaround this even in F# using an unsafe Unchecked.defaultof<_>
value:
let trythis = new Wrapper(Unchecked.defaultof<_>)
This is very useful if you want to check for null
in an object that is exposed to C#:
type Wrapper (value: test) =
if value = Unchecked.defaultof<_> then
invalidArg "value" "Value should not be null."
member val Value = value with get, set
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With