No video

C# Flags Enum Explained - Deep Dive

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

Shiv Kumar

Shiv Kumar

Күн бұрын

Пікірлер: 43
@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
@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.
@SridharSathya
@SridharSathya 9 жыл бұрын
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 9 жыл бұрын
Right you are Sridhar.
@ioannisstefanou9140
@ioannisstefanou9140 4 жыл бұрын
Amazing explanation. Really enjoyed the pace and progression. Excellent tutorial, thank you!
@Matlus
@Matlus 4 жыл бұрын
Glad you enjoyed it
@bomo6453
@bomo6453 3 жыл бұрын
You sir, just saved my life. Thank you so much
@Matlus
@Matlus 3 жыл бұрын
Thank you Bo! Happy to be of help.
@Phcodesign
@Phcodesign 5 жыл бұрын
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 5 жыл бұрын
@Fikret, thank you! I appreciate your comments
@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.
@zzzamo
@zzzamo 4 жыл бұрын
Really easy to understand. Thanks man!
@Matlus
@Matlus 4 жыл бұрын
Thank you Eduardo!
@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!
@autofires
@autofires 9 жыл бұрын
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 6 жыл бұрын
Oh Shiv, you are super star, your simple explanation is made me understand clearly, i will be frequent visitor to your blog. Thank you
@mahdimollaeian8840
@mahdimollaeian8840 2 жыл бұрын
Thanks for the great explanation
@ontherogs
@ontherogs 9 жыл бұрын
Really useful, well explained shift left logic
@ijeanpierrebp
@ijeanpierrebp Жыл бұрын
Great explanation ⭐⭐⭐⭐⭐
@aske1602
@aske1602 9 жыл бұрын
Thanks, best tutorial so far on flags. I have some very specific logic that flags will work well with.
@vkg.codefactory
@vkg.codefactory 6 жыл бұрын
Excellent video, great coverage on enums!
@rickmemmer5625
@rickmemmer5625 6 жыл бұрын
Exceptional! A model of excellence in instruction. Much appreciated!! :o)
@LearnWithVarun
@LearnWithVarun Жыл бұрын
Awesome, helped alot😄😄
@vladgheorghiu2215
@vladgheorghiu2215 6 жыл бұрын
This is explained so genius. Very nice!
@Matlus
@Matlus 6 жыл бұрын
Thank you @Vlad
@gajarubanjeyakumar7226
@gajarubanjeyakumar7226 4 жыл бұрын
Thankyou
@billhefner8034
@billhefner8034 3 ай бұрын
awesome!
@tan3ryigit
@tan3ryigit 9 жыл бұрын
thats great u r back :)
@adrianlara6266
@adrianlara6266 9 жыл бұрын
gracias muy util tu video, segui asi.
@jpegacai104
@jpegacai104 8 жыл бұрын
Great tutorial!
@jayashreereddy5643
@jayashreereddy5643 7 жыл бұрын
Excellent !!
@borisevraev8190
@borisevraev8190 6 жыл бұрын
Thank you!
@dmitryisaevski7765
@dmitryisaevski7765 7 жыл бұрын
#simply the best)
@Matlus
@Matlus 7 жыл бұрын
Thank you!
@ontherogs
@ontherogs 9 жыл бұрын
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,1 М.
.Net Memory Allocations and Performance
52:28
Shiv Kumar
Рет қаралды 32 М.
Schoolboy Runaway в реальной жизни🤣@onLI_gAmeS
00:31
МишАня
Рет қаралды 4 МЛН
Incredible Dog Rescues Kittens from Bus - Inspiring Story #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 28 МЛН
Glow Stick Secret Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 10 МЛН
C# Events and Delegates Made Simple | Mosh
32:04
Programming with Mosh
Рет қаралды 941 М.
To LINQ Or Not To LINQ - That is the Question
32:35
Shiv Kumar
Рет қаралды 3,3 М.
The Most Legendary Programmers Of All Time
11:49
Aaron Jack
Рет қаралды 552 М.
but what is 'a lifetime?
12:20
leddoo
Рет қаралды 70 М.
So You Think You Know C#? - Static classes
28:08
Shiv Kumar
Рет қаралды 10 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 166 М.
Writing Allocation Free Code in C# - Matt Ellis
1:00:15
NDC Conferences
Рет қаралды 70 М.
Кто убил СССР: называем поименно
54:09
НО.Медиа из России
Рет қаралды 43 М.
ARRAYLIST VS LINKEDLIST
21:20
Core Dumped
Рет қаралды 59 М.
Schoolboy Runaway в реальной жизни🤣@onLI_gAmeS
00:31
МишАня
Рет қаралды 4 МЛН