F# 是否与DateTime.MinValue进行模式匹配?

F# 是否与DateTime.MinValue进行模式匹配?,f#,F#,我正在编写一个F#服务,用于轮询另一个服务(已用C#编写): 您使用的模式匹配有点不正确 以下各项应起作用: let effectiveFrom = match storedDate with | d when d = DateTime.MinValue -> System.Nullable() | _ -> System.Nullable(storedDate) 当您

我正在编写一个F#服务,用于轮询另一个服务(已用C#编写):


您使用的模式匹配有点不正确

以下各项应起作用:

    let effectiveFrom = 
        match storedDate with 
        | d when d = DateTime.MinValue -> System.Nullable()
        | _                            -> System.Nullable(storedDate)

当您想作为模式匹配的一部分来测试相等性时,您需要使用一个When子句(请参见此处-

),该子句非常有效,谢谢。谢谢你的链接。
//this doesn't...
let effectiveFrom = 
    match storedDate with 
    | DateTime.MinValue -> System.Nullable()
    | _ -> System.Nullable(storedDate)
    let effectiveFrom = 
        match storedDate with 
        | d when d = DateTime.MinValue -> System.Nullable()
        | _                            -> System.Nullable(storedDate)