advertise with us

Favour Boolean assignment via expressions in C# rather than if/else blocks

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.


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