C# Flags Enum

  Рет қаралды 5,289

Coding Tutorials

Coding Tutorials

Жыл бұрын

In C#, an enum represents a single named value. But with a little bit of work, we can store multiple value in a single enum variable.
Source code available at: github.com/JasperKent/Flags-Enum
Topics include:
- Enum flags convention
- Combining enums with | (or)
- Querying enums with & (and)
- Querying enums with HasFlag
- Improving appearance with the FlagsAttribute
- Selecting enum size

Пікірлер: 17
@CodingTutorialsAreGo
@CodingTutorialsAreGo Жыл бұрын
Flags enums have been around since the beginning of C#. Are there any other old but obscure features that need looking into? Let me know Source code available at: github.com/JasperKent/Flags-Enum Remember to subscribe at kzbin.info/door/qWQzlUDdllnLmtgfSgYTCA And if you liked the video, click the 👍.
@darkmalk94
@darkmalk94 Жыл бұрын
Thanks for the tuto it helped. Though I'm reading existing code which is Public enum A{ B = 1
@CodingTutorialsAreGo
@CodingTutorialsAreGo Жыл бұрын
@@darkmalk94 The
@davidwhite2011
@davidwhite2011 Жыл бұрын
Another great Friday because of Coding Tutorials!
@Jnviana92
@Jnviana92 Жыл бұрын
Found your channel recently and I really enjoy the way you present topics. Thank you for all the lessons
@marklord7614
@marklord7614 Жыл бұрын
If there was a definitive list of C# tutorials, this video belongs in the enum section. It is thorough and well presented. This is why I just subscribed to your channel (actually, your tutorials are top notch, but this just drives the point home.)
@AndrewAndZz
@AndrewAndZz Жыл бұрын
Really great explanation of the topic! Thanks, Jasper!
@10Totti
@10Totti Жыл бұрын
This tutorial is the best!!!!
@wkurnikumnieniema
@wkurnikumnieniema 6 ай бұрын
Thanks man. I had problem to understand those Flags and related operators, but this tutorial explained it very clearly.
@coderstubechannel
@coderstubechannel Жыл бұрын
Great video on C#! I just started my channel dedicated to programming and I'm always looking for inspiration. Can't wait to see more of your content, keep it up!
@Nora-dg1hx
@Nora-dg1hx 6 ай бұрын
Thank you for this it helped me out big time
@DavidGilden
@DavidGilden Жыл бұрын
Brilliant ✌🏼
@UhGoomba
@UhGoomba 2 ай бұрын
thanks babe
@Lonchanick
@Lonchanick 8 ай бұрын
nice!!!!!!!!!!!!!
@libberator5891
@libberator5891 Жыл бұрын
Are there any downsides to numbering them instead with bit-shifting: 0, 1 (or 1
@CodingTutorialsAreGo
@CodingTutorialsAreGo Жыл бұрын
Very good point. I tend to agree, but in the majority of code I've encountered, the numbers are just hardcoded.
@tatjanafelde8415
@tatjanafelde8415 Жыл бұрын
I'd say avoid. Flags enums are limited to 32-bit when you use int-Enums. When you reach the limit of 32 entries, you have to workaround that limit, like reserving the last flag and using a second enum to hold the next set of data. Just use a simple class with bool Properties. Easy to understand, easy to extend in all sort of different ways. You could also use just ISet as a replacement on any enum. It will do the same and you can store the whole int-Range of entries in it.
C# Value Types and Reference Types
32:49
Coding Tutorials
Рет қаралды 4,6 М.
Inheritance in JavaScript - Prototypal Inheritance tutorial
20:06
Would you like a delicious big mooncake? #shorts#Mooncake #China #Chinesefood
00:30
В ДЕТСТВЕ СТРОИШЬ ДОМ ПОД СТОЛОМ
00:17
SIDELNIKOVVV
Рет қаралды 2,5 МЛН
Como ela fez isso? 😲
00:12
Los Wagners
Рет қаралды 33 МЛН
#031 Attributes in C# [  شرح بالعربي ]  #attribute
56:16
Metigator | عصام عبدالنبي
Рет қаралды 6 М.
Stackalloc and Spans
30:17
Coding Tutorials
Рет қаралды 8 М.
Mastering Augmented Assignment Operators: // and % in Python
2:47
AI Insights with Ahsan
Рет қаралды 20
Configuring Await
14:11
Coding Tutorials
Рет қаралды 7 М.
C# 12 Collection Expressions and the Spread Operator
25:27
Coding Tutorials
Рет қаралды 1,5 М.
What is CLR
2:15
C# Programming
Рет қаралды 6 М.
C# Equality and Hashcodes
27:05
Coding Tutorials
Рет қаралды 8 М.
How to write "smarter" enums in C#
12:56
Nick Chapsas
Рет қаралды 133 М.
Use Arc Instead of Vec
15:21
Logan Smith
Рет қаралды 133 М.
ASP.NET Minimal API Performance
10:58
Coding Tutorials
Рет қаралды 2,4 М.
📱 SAMSUNG, ЧТО С ЛИЦОМ? 🤡
0:46
Яблочный Маньяк
Рет қаралды 1,9 МЛН
How charged your battery?
0:14
V.A. show / Магика
Рет қаралды 3,6 МЛН
How To Unlock Your iphone With Your Voice
0:34
요루퐁 yorupong
Рет қаралды 19 МЛН
Задача APPLE сделать iPHONE НЕРЕМОНТОПРИГОДНЫМ
0:57
How much charging is in your phone right now? 📱➡️ 🔋VS 🪫
0:11
Нашел айфоны в мусорке!
0:32
По ту сторону Гугла
Рет қаралды 275 М.