Timeline for Optimal way to use null conditional operators in boolean expressions
Current License: CC BY-SA 3.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 9, 2019 at 14:36 | comment | added | jitbit |
@BenCottrell I would call it a "micro" optimization if the IsManagerVietnamVet property goes to check in a database ;)
|
|
| Apr 9, 2019 at 6:19 | comment | added | Ben Cottrell | @jitbit It's more about maintainability. Micro-optimisations such as the one you mention are generally unnecessary - it's not worth worrying about unless performance is identified as an issue and profiling shows that making changes like that would have any noticeable impact. | |
| Apr 8, 2019 at 21:31 | comment | added | jitbit |
Just keep in mind that long a && b && c &&...are executed sequentially, and the next one is not even executed if the previous one is false. So people usually put fastest at the beginning. Keep that in mind when moving stuff into a separate bool-var
|
|
| Sep 29, 2017 at 7:08 | history | edited | Ben Cottrell | CC BY-SA 3.0 |
Updated with C# 6.0 syntax
|
| Mar 29, 2016 at 12:19 | comment | added | GHP | New C# syntax to save a few lines: public bool IsManagerVietnamVet => (team.Category=="") && (team.Manager?.IsVietnamVet?? false); | |
| Mar 29, 2016 at 4:50 | comment | added | Santhos | I think I am mostly leaning towards such a solution. | |
| Mar 29, 2016 at 4:49 | vote | accept | Santhos | ||
| Mar 27, 2016 at 18:53 | history | edited | Ben Cottrell | CC BY-SA 3.0 |
added 302 characters in body
|
| Mar 27, 2016 at 18:41 | history | answered | Ben Cottrell | CC BY-SA 3.0 |