G
Guest
Been a long time since I dealt with some Bit-Wise operations - and never did
so in C#. Can someone help me with the following, simple example and how to
work with each of my situations (listed below)? I'm sure it's really easy
stuff...
Say I have an enum set up as follows:
[Flags]
public enum DaysOfTheWeek
{
Sunday = 1,
Monday = 2,
Tuesday = 4,
Wednesday = 8,
Thursday = 16,
Friday = 32,
Saturday = 64,
}
And I have a variable set up as follows:
DaysOfTheWeek SomeDays;
Here are my questions...
1. How do I test if SomeDays contains Friday?
2. How can I write a "for" loop that will go through all of the items in the
enum (in other words Sunday..Saturday) and, for each one, tell me if
"SomeDays" has that day flagged as a "1"?
3. How do I specifically set a flag bit to ZERO ("0")? Say I want to clear
the Saturday bit for "SomeDays". How do I do that?
Thanks for the help!
Alex
so in C#. Can someone help me with the following, simple example and how to
work with each of my situations (listed below)? I'm sure it's really easy
stuff...
Say I have an enum set up as follows:
[Flags]
public enum DaysOfTheWeek
{
Sunday = 1,
Monday = 2,
Tuesday = 4,
Wednesday = 8,
Thursday = 16,
Friday = 32,
Saturday = 64,
}
And I have a variable set up as follows:
DaysOfTheWeek SomeDays;
Here are my questions...
1. How do I test if SomeDays contains Friday?
2. How can I write a "for" loop that will go through all of the items in the
enum (in other words Sunday..Saturday) and, for each one, tell me if
"SomeDays" has that day flagged as a "1"?
3. How do I specifically set a flag bit to ZERO ("0")? Say I want to clear
the Saturday bit for "SomeDays". How do I do that?
Thanks for the help!
Alex