如果它是一个子集,是否可以使用一个枚举来代替另一个枚举?
假设我们有两个枚举列表:A和B。枚举A是一件衣服的清单,B是A的一个子集。
我可以使用枚举B代替
enum A //Clothes
{
hats,
pants,
shirts,
gloves,
jacket,
boots,
skirt,
suit,
sweater,
hoodie,
beanie,
...
}
enum B //subset of A, contains only stuff you can put on your head
{
hats = A.hats,
beanie = A.beanie,
...
}
A吗?
例如,在字典中字典< a,t> foo
,我该怎么做:foo [b.hats]
?
Let's say we have two enum lists: A and B. Enum A is a list of clothes, and B is a subset of A.
Example
enum A //Clothes
{
hats,
pants,
shirts,
gloves,
jacket,
boots,
skirt,
suit,
sweater,
hoodie,
beanie,
...
}
enum B //subset of A, contains only stuff you can put on your head
{
hats = A.hats,
beanie = A.beanie,
...
}
Can I use enum B in place of A?
For example, in a dictionary Dictionary<A, T> foo
, how can I do: foo[B.hats]
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在枚举之间进行转换。
You can cast between enums.