2 variables and data types
TRANSCRIPT
![Page 2: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/2.jpg)
Using variables
Memory is allocated to a variable at the time of its creation.
Syntax:
<datatype> <variableName>;
int empNumber;
empNumber = 100;
string empName = “M. Nolan”;
![Page 3: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/3.jpg)
Data Types
Value Types
store actual values.
the values are stored in stack.
int, float, double, …
Reference Types
store the memory address
of other variables
in heap
string, class
![Page 4: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/4.jpg)
![Page 5: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/5.jpg)
Classification
Object
String
Class
Delegate
Interface
Array
![Page 6: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/6.jpg)
Rules
Recommended CAMELCASE
int totMonths = 12
![Page 7: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/7.jpg)
Question?
![Page 8: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/8.jpg)
Question?
![Page 9: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/9.jpg)
Comments and XML Documentation
![Page 10: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/10.jpg)
Definition
Single-line Comments
Multi-line Comments
XML Comments
![Page 11: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/11.jpg)
XML Documentation
![Page 12: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/12.jpg)
Predefined XML Tags
![Page 13: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/13.jpg)
Constants and Literals
![Page 14: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/14.jpg)
Constants
possible to declare constants for all data types.
have to initialize a constant at the time of its declaration.
The compiler identify constants at the time of compilation
![Page 15: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/15.jpg)
Using Literals
A literal is a static value assigned to variables and constants.
Numeric literals might suffix with a letter of the alphabet to indicate the data type of the literal.
Boolean => bool
Integer => int, uint (u), long (l), ulong (ul or lu)
long val = 53L;
Real => float(f), double(d), decimal(m)
float val = 1.66f;
Character
String => regular or verbatim.
Null
![Page 16: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/16.jpg)
Keywords and Escape Sequences
![Page 17: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/17.jpg)
Keywords
![Page 18: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/18.jpg)
Escape Sequence Characters
![Page 19: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/19.jpg)
Input and Output
![Page 20: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/20.jpg)
Console Operations
are tasks performed on the command line interface.
All console application consist of three streams
Standard in
Standard out
Standard err
![Page 21: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/21.jpg)
Output Methods
Console.Write()
Console.WriteLine()
![Page 22: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/22.jpg)
Placeholders
![Page 23: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/23.jpg)
Input Methods
Console.Read()
Console.ReadLine()
![Page 24: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/24.jpg)
Convert Methods
![Page 25: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/25.jpg)
Numeric Format Specifiers
Console.WriteLine(“{format specifier}, <variable name>”);
![Page 26: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/26.jpg)
Numeric Format Specifiers
![Page 27: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/27.jpg)
Standard Date and Time Format Specifiers
![Page 28: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/28.jpg)
Standard Date and Time Format Specifiers
![Page 29: 2 variables and data types](https://reader033.vdocuments.mx/reader033/viewer/2022052505/554eba77b4c905de468b4681/html5/thumbnails/29.jpg)
Question
What is result of following code snippet?