Professional Documents
Culture Documents
Lecture 1
Variables
A name you give to a storage location in memory.
Constants make our programs more safe by protecting unchangeable values from accidental
changes.
Declaring a variable:
type identifier;
You should always initialize constant variables and you should initialize a variable before
using it.
Identifier Naming Rules
- Can’t start with a number
- Can’t contain whitespaces
- Can’t be a reserved keyword.
Naming Conventions :
byte 1 Byte
short 2 Int16
int 4 Int32
long 8 Int64
float 4 Single
double 8 Double
decimal 16 Decimal
char 2 Char
bool 1 Boolean
Non-primitive Data types
- String
- Array
- Class
Variables and …
- Scopes
- Type Conversion:
- Implicit Conversion
- Explicit Conversion (Type Casting)
- Conversion between non-compatible types
Demo: Greeter Program
Operators
- String Length
- Concatenation
- Special Characters
- Accessing string characters
If… else
if (condition)
{
// block of code to be executed if the condition is True
}
else
{
// block of code to be executed if the condition is False
}
Ternary Operator
while (condition) do
{ {
} }
while (condition);
For Loop
- Method Parameters
- Default/ Optional Parameters
- Static Methods
- Return Values
- Method Overloading