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”;
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
Classification
Object
String
Class
Delegate
Interface
Array
Rules
Recommended CAMELCASE
int totMonths = 12
Question?
Question?
Comments and XML Documentation
Definition
Single-line Comments
Multi-line Comments
XML Comments
XML Documentation
Predefined XML Tags
Constants and Literals
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
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
Keywords and Escape Sequences
Keywords
Escape Sequence Characters
Input and Output
Console Operations
are tasks performed on the command line interface.
All console application consist of three streams
Standard in
Standard out
Standard err
Output Methods
Console.Write()
Console.WriteLine()
Placeholders
Input Methods
Console.Read()
Console.ReadLine()
Convert Methods
Numeric Format Specifiers
Console.WriteLine(“{format specifier}, <variable name>”);
Numeric Format Specifiers
Standard Date and Time Format Specifiers
Standard Date and Time Format Specifiers
Question
What is result of following code snippet?
Top Related