C# Flags Enum Explained - Deep Dive

  Рет қаралды 14,442

Shiv Kumar

Shiv Kumar

Күн бұрын

Пікірлер: 43
@jessegador
@jessegador 4 жыл бұрын
The most compact and best video for masking. Thanks for the great explanation. Now I'm subscribed to your channel.
@Matlus
@Matlus 4 жыл бұрын
Thank you for your kind words Jesse! Thank you also for subscribing.
@Phcodesign
@Phcodesign 6 жыл бұрын
When it is clear to yourself then it is pretty easy your words and explanations to be clear to the audience. Thank you for this excellent video!
@Matlus
@Matlus 6 жыл бұрын
@Fikret, thank you! I appreciate your comments
@ioannisstefanou9140
@ioannisstefanou9140 5 жыл бұрын
Amazing explanation. Really enjoyed the pace and progression. Excellent tutorial, thank you!
@Matlus
@Matlus 5 жыл бұрын
Glad you enjoyed it
@vishnupv2008
@vishnupv2008 4 жыл бұрын
I used this today. Your video was great help!
@Matlus
@Matlus 4 жыл бұрын
That's great Punnoor! Good to hear this video helped you.
@sudheernani2470
@sudheernani2470 2 жыл бұрын
Here I am trying to find what the concept of flags with enum, and this explanation of yours is crystal clear.. Thank you
@SridharSathya
@SridharSathya 10 жыл бұрын
Thanks but I'd check your explanation around 17:55 and after. Specifically how we'd turn off a bit; most of us get it wrong often. If I want to remove Tuesday XOR will not remove Tuesday if it is not set - in fact it will turn it on. If I want to remove Tuesday if it turned on or off days = days & ~Weekdays.Tuesday//i.e. and with not Weekdays.Tuesday will ensure Tuesday is turned off irrespective if it is on or off.
@Matlus
@Matlus 10 жыл бұрын
Right you are Sridhar.
@zzzamo
@zzzamo 4 жыл бұрын
Really easy to understand. Thanks man!
@Matlus
@Matlus 4 жыл бұрын
Thank you Eduardo!
@bomo6453
@bomo6453 3 жыл бұрын
You sir, just saved my life. Thank you so much
@Matlus
@Matlus 3 жыл бұрын
Thank you Bo! Happy to be of help.
@ijeanpierrebp
@ijeanpierrebp Жыл бұрын
Great explanation ⭐⭐⭐⭐⭐
@autofires
@autofires 10 жыл бұрын
Another brilliant video. Very well prepared with clear explanations and professionally delivery. I hope you continue with these lessons. Many Thanks Mr Kumar, धन्यवाद
@starman9000
@starman9000 7 жыл бұрын
Oh Shiv, you are super star, your simple explanation is made me understand clearly, i will be frequent visitor to your blog. Thank you
@vladgheorghiu2215
@vladgheorghiu2215 6 жыл бұрын
This is explained so genius. Very nice!
@Matlus
@Matlus 6 жыл бұрын
Thank you @Vlad
@ontherogs
@ontherogs 10 жыл бұрын
Really useful, well explained shift left logic
@mahdimollaeian8840
@mahdimollaeian8840 2 жыл бұрын
Thanks for the great explanation
@vkg.codefactory
@vkg.codefactory 6 жыл бұрын
Excellent video, great coverage on enums!
@aske1602
@aske1602 10 жыл бұрын
Thanks, best tutorial so far on flags. I have some very specific logic that flags will work well with.
@LearnWithVarun
@LearnWithVarun 2 жыл бұрын
Awesome, helped alot😄😄
@rickmemmer5625
@rickmemmer5625 6 жыл бұрын
Exceptional! A model of excellence in instruction. Much appreciated!! :o)
@tan3ryigit
@tan3ryigit 10 жыл бұрын
thats great u r back :)
@gajarubanjeyakumar7226
@gajarubanjeyakumar7226 4 жыл бұрын
Thankyou
@jpegacai104
@jpegacai104 8 жыл бұрын
Great tutorial!
@adrianlara6266
@adrianlara6266 9 жыл бұрын
gracias muy util tu video, segui asi.
@billhefner8034
@billhefner8034 7 ай бұрын
awesome!
@jayashreereddy5643
@jayashreereddy5643 7 жыл бұрын
Excellent !!
@borisevraev8190
@borisevraev8190 7 жыл бұрын
Thank you!
@dmitryisaevski7765
@dmitryisaevski7765 7 жыл бұрын
#simply the best)
@Matlus
@Matlus 7 жыл бұрын
Thank you!
@matejzajacik8496
@matejzajacik8496 2 жыл бұрын
If you just want to know if the bit is set or not, you can also just test against zero; you don't have to test against the bit itself. So instead of: var tuesdayIsInSet = (days & Weekdays.Tuesday) == Weekdays.Tuesday; You can just write: var tuesdayIsInSet = (days & Weekdays.Tuesday) > 0; Or if you need to test for the absence of the bit: var tuesdayIsNotInSet = (days & Weekdays.Tuesday) == 0; This way, you don't need to update the right-hand side every time you change the left-hand side, and it's less typing.
@ijeanpierrebp
@ijeanpierrebp Жыл бұрын
great!
@ontherogs
@ontherogs 10 жыл бұрын
Real
@adrianiordache4391
@adrianiordache4391 4 жыл бұрын
I don't think you will ever use such thing in your career as a developer.
@Matlus
@Matlus 4 жыл бұрын
Hi Adrian, I'm afraid, I' don't understand your comment. I've read it several times but I don't get it.
@Matlus
@Matlus 4 жыл бұрын
I beg to differ Adrian. I use this a lot and have been using this feature even before C# (that is other languages).
@adrianiordache4391
@adrianiordache4391 4 жыл бұрын
@@Matlus Which problems does this solves exactly that other data structures or statements could not? Is this more efficient?
@Matlus
@Matlus 4 жыл бұрын
@@adrianiordache4391 It's not about what problem flags enums solve that you can't do any other way. It's about using the correct solution for the job. These are flags enums, that is a combination of bits can be turned on/off. And you want to know with a single conditional statement which bits are off and which bits are on. Or you want to flip a bit (that is no matter what the state of the bit is, you want to flip it. Or set a bit if it's off or turn off a bit if it is set So for example, is a user in a certain role? A user could be in multiple security roles but are they in this role? Suppose you want to perform certain "set"actions. Suppose these actions will fail but you need to keep trying till all actions are complete. Each action is a bit turned off. Keep trying till all bits are off. They key thing to keep in mind is there for 32 bits (things) these is exactly on variable. and not 32 variables (or a structs that has 32 properties). Just one variable but with sets of possible states.
Unit Testing Rebooted
48:34
Shiv Kumar
Рет қаралды 3,2 М.
C# Flags Enum
12:35
Coding Tutorials
Рет қаралды 7 М.
IL'HAN - Qalqam | Official Music Video
03:17
Ilhan Ihsanov
Рет қаралды 700 М.
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
C#'s Enum performance trap your code is suffering from
9:54
Nick Chapsas
Рет қаралды 58 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 846 М.
Enums, Flags, and Bitwise operations [C# / DotNet]
9:09
Data Vids (Data Vids)
Рет қаралды 2,9 М.
Bitwise Operators and WHY we use them
8:41
Alex Hyett
Рет қаралды 96 М.
How Air Traffic Control Works & Bird Strike Prevention
32:58
Not What You Think
Рет қаралды 108 М.
How To Create Smart Enums in C# With Rich Behavior
17:31
Milan Jovanović
Рет қаралды 57 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 846 М.
C# Events and Delegates Made Simple | Mosh
32:04
Programming with Mosh
Рет қаралды 955 М.
C# enums 🪐
7:07
Bro Code
Рет қаралды 76 М.