This is the third part of the third part my C# tutorial – some optional questions about variables to help your understanding of this section. You can choose to skip them if you so wish.
1) Rearrange the following code into one line:
counter = 12;
2) Rearrange the following code into one line:
int counter, other;
counter = 12;
int myint = 10;
other = 5;
HINT: You can declare multiple variables on one line by putting commas between each declaration and the semi colon after the last one
3) What does the assignment operator look like?
4) What is ‘int’ short for?
5) Can a signed variable hold negative values?
6) Which type is signed: short or ushort?
7) Which type can hold your name: bool or string?
8 ) What is wrong with the following code?
string myname = Hi it’s Matt!;
9) What colour do strings turn when they are typed? (in Microsoft Visual C# 2010)
10) What is wrong with the following code?
string number1 = 5, number2 = 3;
int answer = number1 + number2;
1) int counter = 12;
2) int counter = 12, other = 5, myint = 10;
8 ) The value I was trying to assign to the string I had just created wasn’t a string value because it wasn’t in double quotes. It wasn’t the name of another string variable because it had a space and an exclamation mark
10) a) You can’t add together numbers in strings because they count as text. b) You can’t assign two strings added together to an integer variable
Part 4.0 will be about operators