Professional Documents
Culture Documents
© PakDev.net
Agenda
Understanding Value Types
Creating and Using Variables
Formatting Console Output
© PakDev.net
Value Types
Directly contain their data
Each has its own copy of data
Operations on one cannot affect another
© PakDev.net
Naming Variables and Rules
Rules
Use letters, the Answer42
underscore, and digits 42Answer
Recommendations
Avoid using all
different
Different
uppercase letters
Avoid starting with
an underscore
BADSTYLE
Avoid using
_poorstyle
BestStyle
abbreviations
Use PascalCasing
naming in multiple-word
Msg
Message
names
© PakDev.net
Declaring Local Variables
Usually declared by data type and
variable name:
int itemCount;
© PakDev.net
Compound Assignment
Adding a value to a variable is very common
itemCount = itemCount + 40;
© PakDev.net
Increment and Decrement
Changing a value by one is very common
itemCount += 1;
itemCount -= 1;
© PakDev.net
Common Value Types
© PakDev.net
Common Value Types
© PakDev.net
String Formatting Example
© PakDev.net
DateTime Formatting
© PakDev.net
Value Types and Formatting
Demo
© PakDev.net
Demonstration Steps
Create a new console application
Create short integer variables
Apply some operations on variables
Read user input into string variables
Apply formatting on currency and date values
© PakDev.net
Thank you
PakDev.net
© PakDev.net