C
Charlie
Below is code for testing whether an enum is part of
a "set" of enums. There must be some better way to do
this. How does one get a group of enums and test for
inclusion? I want to use sets. But maybe collections?
What is the right way to proceed?
enum Suit: int {spade=1, club=2, heart=4,
diamong=8};
private void button1_Click(object sender,
System.EventArgs e)
{
Suit blackSuits = Suit.spade |
Suit.club;
if ((blackSuits & Suit.club) != 0)
MessageBox.Show
(this, "Yes");
else
MessageBox.Show
(this, "No");
}
a "set" of enums. There must be some better way to do
this. How does one get a group of enums and test for
inclusion? I want to use sets. But maybe collections?
What is the right way to proceed?
enum Suit: int {spade=1, club=2, heart=4,
diamong=8};
private void button1_Click(object sender,
System.EventArgs e)
{
Suit blackSuits = Suit.spade |
Suit.club;
if ((blackSuits & Suit.club) != 0)
MessageBox.Show
(this, "Yes");
else
MessageBox.Show
(this, "No");
}