How to avoid evaluating a short circuit in C # while performing the same function

We have some kind of operator in C #, thanks to which I can avoid evaluating a short circuit and go to all conditions.

say

if(txtName.Text.xyz() || txtLastName.Text.xyz()) { } public static bool xyz(this TextBox txt) { //do some work. return false; } 

He must evaluate all conditions regardless of the results obtained. And after evaluating the last condition, it continues in accordance with the result.

+7
operators c # short-circuiting
source share
2 answers

Just use one line, this will evaluate both arguments regardless of the result of the first result.

 if(txtName.Text.xyz() | txtLastName.Text.xyz()) { } 

You can also do the same with AND, i.e. you can replace && with one ampersand to get the same effect as above:

 if(txtName.Text.xyz() & txtLastName.Text.xyz()) { } // Both sides will be called 
+13
source share

Just use a single panel;

 if(txtName.Text.xyz() | txtLName.Text.xyz()) { } 
+4
source share

All Articles