Where applicable favour Boolean assignment via expressions rather than if/else blocks. The first example below is still so common but the 2nd and 3rd examples require much less code without sacrificing readability.

Note… Visual Studio has a nice refactor to help converting relevant if/else blocks to an expression.
Grab Your Free C# Cheat Sheet!
Download "C# Essentials: A Developer's Cheat Sheet" for key syntax, tips, and quick references. Perfect for developers of all levels!
👉 Download your free copy now!Need Help with Your C# Projects?
We offer expert support and development services for projects of any size. Contact us for a free consultation and see how we can help you succeed.
CONTACT US NOW