This errors:
double z;
int? x = 0;
int? y = 0;
z = (double)x -= (double)y;
..this does not error:
double z;
int? x = 0;
int? y = 0;
double x_con = (double)x;
double y_con = (double)y;
z = x_con -= y_con;
Simple question. Why?
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.
If fails on this alone, without the
z:Simply because the left hand side of an assignment operator must be a variable, property or indexer, and not another expression, like your cast is.
Your second example however has the assignment written like this:
And that is perfectly fine of course since
x_conis a variable.