I'm using F# 4.7 with <LangVersion>preview</LangVersion>
in my project file.
I have a type like this:
type Record = {
Name : string
Description : string
FieldNotInterestedIn: int
}
I'd like to get the names of certain fields in a type-safe way, but not all of them. I know I can get all the field names using reflection.
Here's the most concise code I came up with. Can it be any more concise?
let certainFieldNames =
let r = Unchecked.defaultof<Record>
[
nameof r.Name
nameof r.Description
]
Aucun commentaire:
Enregistrer un commentaire