in the example below, what would ‘foo’ be set to each time? I’ve searched online but I can’t find anywhere that gives me the answer:
static void Main(string[] args) {
static public bool abc = true;
static public bool foo = (abc = false);
foo = (abc = true);
}
falsethe first time andtruethe second time. Remember that=is the assignment operator: it assigns the value of the second operand to the first, and then returns this value. For example:The second line here assigns the 2 to
foo, then returns 2 to the other assignment operator, which assigns 2 to bar. At the end of it all, bothfooandbarhave the value 2.Edit: This is why it’s valid to chain up assignment operations; e.g.