Friday, September 18, 2015

compound assignment operators in C#

We've probably all seen the &= in string concatenation but did you know that is also exists in boolean assignments?

isFoo &= isBar;

 
 

...is kind of like...

isFoo = (isFoo && isBar);

 
 

...assuming both isFoo and isBar are bool types. There is also...

isFoo |= isBar;

 
 

...should one of the two be true per this.

No comments:

Post a Comment