The Ultimate Beginner's Guide to Flags Enums in CSharp

Поделиться
HTML-код
  • Опубликовано: 16 ноя 2024

Комментарии • 9

  • @2u1u
    @2u1u Год назад +1

    Great video. I've never come across a need to use flags. I am curious about others use cases for using flags though.

    • @DevLeader
      @DevLeader  Год назад

      Awesome! I'm glad that you found it helpful!
      In practice I find I almost never use them to be honest. It was a lot more common when I did embedded coding but very rare in C#.

  • @mahdignb
    @mahdignb 11 месяцев назад +1

    Great explanation. Is it bad practice to use decimal values for flags from the beginning?

    • @DevLeader
      @DevLeader  11 месяцев назад

      Great question! My generic answer is: it depends! 😁
      I think the goal is readability here. I'd argue maintainability and flexibility *shouldn't* be as important with Enums because ideally you're not touching them again 😉 so readability takes priority here for me.
      With that said, if you and your team are more comfortable working with decimal (and you understand behind the scenes it's using bits for the flags) then I see no issue.
      I opt for binary just so that I'm thinking in bits and have my head on straight 🙂

    • @mahdignb
      @mahdignb 11 месяцев назад

      @@DevLeader Thank you

  • @narendra672
    @narendra672 8 месяцев назад +1

    👏👍

    • @DevLeader
      @DevLeader  8 месяцев назад

      Thanks! I hope that you found this helpful 🙂

  • @robertmrobo8954
    @robertmrobo8954 Год назад

    What did I just watch..? 🙆‍♂

    • @DevLeader
      @DevLeader  Год назад

      Hey there! Is there anything I can clarify from the video? I'm sorry if it didn't come through clearly!