I'm writing some F# code and I'd like to use an enum value defined in a c# assembly.
For instance, in the c# assembly I've got this code
public enum MyEnum
{
valueA,
valueB,
valueC
}
How do I call MyEnum.valueA
in F#? When I just write that, the compiler shouts:
Invalid use of a type name and/or object constructor. If necessary use 'new' and apply the constructor to its arguments, e.g. 'new Type(args)'. The required signature is: MyEnum()
OK... I'm sorry, I've found my problem... My C# code was actually:
public enum MyEnum
{
@valueA,
@valueB,
@valueC
}
I know, it's weird, but actually it isn't really "my" c# code...
To call it in F#, I have to write:
MyEnum.``valueA``
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