DaveDev DaveDev - 2 months ago 6
C# Question

What does '&=' mean?

in the context of the following:

bool isValid = true;
isValid &= ValidateField(x => x.A);
isValid &= ValidateField(x => x.B);
isValid &= ValidateField(x => x.C);
return isValid;


I'm not sure how to read that code.

What does
&=
mean?

Answer

It's similar to += that is:

isValid &= ValidateField(x => x.A);

Is the same as:

isValid = isValid & ValidateField(x => x.A);

See https://msdn.microsoft.com/en-us/library/e669ax02.aspx for more details on &= and https://msdn.microsoft.com/en-us/library/sbf85k1c.aspx for more details on &

Comments