Your SlideShare is downloading. ×
Variables - Value and Reference Type
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Variables - Value and Reference Type

724

Published on

Variables - Value and Reference Type, Non-Static Vs Static Classes

Variables - Value and Reference Type, Non-Static Vs Static Classes

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
724
On Slideshare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Software Programming and FundamentalsRecap what we covered in week #1
  • 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

×