f# pattern matching with types

后端 未结 5 1213
走了就别回头了
走了就别回头了 2021-01-01 20:31

I\'m trying to recursively print out all an objects properties and sub-type properties etc. My object model is as follows...

type suggestedFooWidget = {
            


        
5条回答
  •  鱼传尺愫
    2021-01-01 21:04

    Here is how I got it to work...

     let getMethod = prop.GetGetMethod()
     let value = getMethod.Invoke(o, Array.empty)
         ignore <|
             match value with
             | :? float as f -> sb.Append(f.ToString() + ", ") |> ignore
                                ...
    

提交回复
热议问题