如何枚举枚举/类型的F#

编程入门 行业动态 更新时间:2024-10-26 06:26:36
本文介绍了如何枚举枚举/类型的F#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有像这样定义枚举类型:

键入标签=     | ART = 0     | N = 1     | V = 2     | P = 3     | NULL = 4

有没有办法做一个的...在标签做?

这是我收到的错误:

  

的值,构造函数,命名空间或   键入标签没有定义

解决方案

使用的 Enum.GetValues​​ :

让allTags = Enum.GetValues​​(typeof运算<标签>)

I've got an enumeration type defined like so:

type tags = | ART = 0 | N = 1 | V = 2 | P = 3 | NULL = 4

is there a way to do a for ... in tags do ?

This is the error that I'm getting:

The value, constructor, namespace or type tags is not defined

解决方案

Use Enum.GetValues:

let allTags = Enum.GetValues(typeof<tags>)

更多推荐

如何枚举枚举/类型的F#

本文发布于:2023-07-30 15:20:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1250597.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:类型

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!