Declaring and setting two variables to signify two different salaries
I'll begin by inserting comment 7 on the line below the open curly brace:
//7. line declares and sets two variables to represent two different salaries
Now, in C#, when the data type of a variable is the same as the data type of another variable, you can put them on the same line, as shown here:
//7. line declares and sets two variables to represent two different salaries decimal salaryOne = 25000, salaryTwo = 65000;
Now type decimal
, which is a good data type for storing monetary values. Then you can enter salaryOne
, which is equal to some value, say 25000
. Put a comma and then you don't have to type decimal
again: you can simply enter salaryTwo
and set that equal to 65000
. So, when the data type is the same, you write it once and then make a list of variable assignments on the rest of the line.
Adding the two salaries
When you type salaryOne + salaryTwo
, the addition (plus) sign here is an operator. Operators, as you know...