0

I have a question about enums

hallo, I don't understand this part of the code:: (meetingDays & Days.Tuesday) == Days.Tuesday; :: why can't I just write meetingDays == Days.Tuesday and why isnt it true because Days.Tuesday and Days.Tuesday are the same and so it should be true or? class Program { public enum Days { None = 0b_0000_0000, // 0 Monday = 0b_0000_0001, // 1 Tuesday = 0b_0000_0010, // 2 Wednesday = 0b_0000_0100, // 4 Thursday = 0b_0000_1000, // 8 Friday = 0b_0001_0000, // 16 Saturday = 0b_0010_0000, // 32 Sunday = 0b_0100_0000, // 64 Weekend = Saturday | Sunday } bool isMeetingOnTuesday = (meetingDays & Days.Tuesday) == Days.Tuesday; Console.WriteLine(

quot;Is there a meeting on Tuesday: {isMeetingOnTuesday}"); // Output: // Is there a meeting on Tuesday: False I found the code on this website [url]https://docs.microsoft.com/de-de/dotnet/csharp/language-reference/builtin-types/enum[/url]

7th Apr 2020, 7:25 AM
Michael
2 Réponses
+ 1
thank you I think I understand it now
7th Apr 2020, 5:31 PM
Michael