Lab: practise the data types
Reading about types is not the same as using them. This lab puts each one into a page and prints it.
The task
Create a page, declare one variable of each common type, and write their values into a label. Build it, run it, then change a value and run it again.
C#
int lessonCount = 7;
double rating = 4.5;
bool isFinished = false;
string learnerName = "Sam";
resultLabel.Text =
learnerName + " has " + lessonCount + " lessons";What to notice
- A whole number and a decimal number are different types.
- A boolean holds only two possible values.
- Joining a number to text converts it for display.
Then break it on purpose. Put a word where a number is expected and read the compiler message. Understanding that message now will save you later.
Carry on with the second half of this lab.