2. Variable Variable: imagine like a box to store one thing (data) Eg: int age; age = 5;
3. Variable Variable: imagine like a box to store one thing (data) Eg: int age; age = 5; int - Size of variable must be big enough to store Integer
4. Variable Variable: imagine like a box to store one thing (data) Eg: int age; age = 5; int - Size of variable must be big enough to store Integer age - Name of variable age
5. Variable Variable: imagine like a box to store one thing (data) Eg: int age; age = 5; 5 int - Size of variable must be big enough to store Integer age - Name of variable age age = 5 – Put a data 5 into the variable
6. Value Type Vs Reference Type Variables: two types Value type (simple type like what you just saw) Only need to store one thing (5, 3.5, true/false, ‘C’ and “string”) Reference type (complex type for objects) Need to store more than one thing (age + height + run() + … )
7. Reference Type Reference type (complex type for objects) Eg: Human john; john = new Human(); Compare this to int age; age = 5;
8. Reference Type Reference type (complex type for objects) Eg: Human john; john = new Human(); Human - Size of variable must be big enough to store an Address
9. john Reference Type Reference type (complex type for objects) Eg: Human john; john = new Human(); Human - Size of variable must be big enough to store an Address john - Name of variable
10. Reference Type Reference type (complex type for objects) Eg: Human john; john = new Human(); D403 age … Human - Size of variable must be big enough to store an Address height john - Name of variable john john = new Human() – Get a house with enough space for john (age, height, etc)
11. Non-Static Vs Static Class Non-Static: need New() to instantiate / create an object – like what you see just now Static: no need to use New() to use, there is just one copy of the class. This type of class basically to provide special functions for other objects So if you see a class being used without New(): it is a static class EgMath class age = Math.Round(18.5); // Math rounding
12. Using Console Program for problem solving Console program: Simple Procedural (from top to bottom) Getting inputs: From arguments: How? From keyboard: How? Exercise 2.1 – 2.5 Language fundamental: int, double, string, Console.WriteLine(), Console.Write(), Console.ReadLine(), int.Parse(), double.Parse(), simple if then statement Problem solving: repeating, swopping of 2 variables, simple sorting