C# Flags Enum

Sdílet
Vložit
  • čas přidán 2. 02. 2023
  • 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
  • Věda a technologie

Komentáře • 18

  • @CodingTutorialsAreGo
    @CodingTutorialsAreGo  Před rokem +4

    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 czcams.com/channels/qWQzlUDdllnLmtgfSgYTCA.html
    And if you liked the video, click the 👍.

    • @darkmalk94
      @darkmalk94 Před rokem

      Thanks for the tuto it helped. Though I'm reading existing code which is
      Public enum A{
      B = 1

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  Před rokem

      @@darkmalk94 The

  • @anathrax6744
    @anathrax6744 Před 5 dny +1

    One of the best tutorials I've ever seen on a specific topic. Kudos

  • @Jnviana92
    @Jnviana92 Před rokem +4

    Found your channel recently and I really enjoy the way you present topics.
    Thank you for all the lessons

  • @marklord7614
    @marklord7614 Před rokem +1

    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.)

  • @davidwhite2011
    @davidwhite2011 Před rokem +2

    Another great Friday because of Coding Tutorials!

  • @AndrewAndZz
    @AndrewAndZz Před rokem +3

    Really great explanation of the topic! Thanks, Jasper!

  • @10Totti
    @10Totti Před rokem +4

    This tutorial is the best!!!!

  • @wkurnikumnieniema
    @wkurnikumnieniema Před 7 měsíci +1

    Thanks man. I had problem to understand those Flags and related operators, but this tutorial explained it very clearly.

  • @Nora-dg1hx
    @Nora-dg1hx Před 6 měsíci +1

    Thank you for this it helped me out big time

  • @DavidGilden
    @DavidGilden Před rokem +1

    Brilliant ✌🏼

  • @UhGoomba
    @UhGoomba Před 3 měsíci +1

    thanks babe

  • @coderstubechannel
    @coderstubechannel Před rokem +2

    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!

  • @Lonchanick
    @Lonchanick Před 8 měsíci +1

    nice!!!!!!!!!!!!!

  • @libberator5891
    @libberator5891 Před rokem +1

    Are there any downsides to numbering them instead with bit-shifting: 0, 1 (or 1

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  Před rokem

      Very good point. I tend to agree, but in the majority of code I've encountered, the numbers are just hardcoded.

  • @tatjanafelde8415
    @tatjanafelde8415 Před rokem

    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.