How To Create Smart Enums in C# With Rich Behavior



Support me on Patreon to access the source code:
https://www.patreon.com/milanjovanovic

Enums are a great way to improve readability in your code. But enums in C# have a minor problem – you can’t add behavior to enum elements. You can only work with enum values. In this, I will show you how you can create a custom smart enum implementation that can contain behavior.

Join my weekly .NET newsletter:
https://www.milanjovanovic.tech

Read my Blog here:
https://www.milanjovanovic.tech/blog

Subscribe for more:
https://www.youtube.com/c/MilanJovanovicTech?sub_confirmation=1

Chapters
0:00 The problem with C# enums
1:16 Creating the Enumeration class
5:11 Implementing Enumeration in CreditCard
8:44 Completing Enumeration implementation
13:17 Adding logic to CreditCard enum

Comments are closed.