Is there any way (just out of curiosity because I came across multiple same-value assignments to multiple variables today) in C# to assign one value to multiple variables at
int num1=5,num2=5
Declaring and assigning variables in the same statement.
Something like this.
num1 = num2 = 5
It is simple.
int num1,num2;
num1 = num2 = 5;
Try this:
num1 = num2 = 5;
Note that this won't work in VB.
Your example would be:
int num1 = 1;
int num2 = 1;
num1 = num2 = 5;