DaveDev DaveDev - 1 year ago 131
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

Answer Source

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 &

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download