相关疑难解决方法(0)

.Net常量的F#模式匹配

下一个例子中的代码,

open System.Drawing

let testColor c =
    match c with
    | Color.Black -> 1
    | Color.White -> 0
    | _ -> failwith "unexpected color"
Run Code Online (Sandbox Code Playgroud)

不编译.错误是Error 1 The field, constructor or member 'Black' is not defined.

如何模拟以大写字母开头的.Net常量或枚举的匹配?

对于它的价值,编译器是"Microsoft(R)F#2.0 Interactive build 4.0.30319.1".

f# pattern-matching

3
推荐指数
2
解决办法
379
查看次数

标签 统计

f# ×1

pattern-matching ×1