How to define type member constant in F#?
问题 In C# one can define a type member constant like this: class Foo { public const int Bar = 600; } The IL looks like this. .field public static literal int32 Bar = int32(600) How can I do the same within Visual F# / FSharp? I tried this to no avail: [<Sealed>] type Foo() = [<Literal>] let Bar = 600 回答1: I did a couple of experiments with the F# compiler and here are some my observations. If you want to create IL literal, then you need to place the value marked as a Literal inside a module. For