In my hunt for some help to a problem I was having I came across this:
p.Enabled = p.Enabled != true;
What exactly does this mean? Ive never seen it before,
nb: the preceeding line was var p = this.PageRepository.GetPage(id);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When
p.Enabledis a normalbool, as Enabled properties usually are,is the same as
in other words: it flips or toggles
p.Enabled.Now when Enabled is a
bool?, shorthand forNullable<bool>, the results are different:So
p.Enabled = p.Enabled != truewill settruewhen the old value wasfalseornull.