Sorry for this stupid question, but I can't find answer for it. So, why I can't write code like this in C#:
int a = 10, b = 20, c = 30, d = 40;
a = b, c = d;
In C++ I can write it and it will be ok.
Why it doesn't compile in C#?
You can write the first line. That is allowed in C#, and spelled out in section 8.5.1 of the C# Language Spec, where it shows that each local-variable-declarator can be in a list that's comma separated:
local-variable-declarators:
local-variable-declarator
local-variable-declarators , local-variable-declarator
However, C# does not have a comma operator like C++, so you have to split the second line:
int a = 10, b = 20, c = 30, d = 40;
a = b;
c = d;