Type is a Template, which describes domain element!
Creating object from type is called instantiating
The object created by instantiating a type is called either an object of the type or an instance of the type.
1:
|
|
C# provides 16 predefined types, including 13 simple types and 3 non-simple types:
There are six kinds of such types:
A type is creating using a type declaration, which includes the following information:
A variable is a name that represents data stored in memory during program execution.
Main characteristics of a variable - its type and value.
1:
|
|
1: 2: |
|
1:
|
|
1:
|
|
var can be used when it’s possible to determine type of variable.
var is allowed:
1: 2: 3: 4: |
|
var is not allowed:
1:
|
|
Some variables might come without initialization, what is the behaviour of C# compiler in regard to these variables?
There are two places the .NET framework stores items in memory as your code executes: Heap and Stack
The stack is an array of memory that acts as LIFO data structure.
Reference types require two segments of memory:
Reference could be null, which means no object in heap to reference
Syntax:
1: 2: |
|
Check variable for null:
1: 2: |
|
Casting:
1: 2: 3: |
|
Array example:
1: 2: 3: |
|
Array initializer:
1: 2: 3: 4: |
|
Multidimensional arrays - always have rectangular shape (rectangle, parallelepiped)
Example:
1: 2: |
|
Jagged arrays - might have rectangular shape (but not necessary)
Example:
1: 2: 3: |
|
Jagged array declaration:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: |
|
1: 2: 3: 4: 5: 6: |
|