Professional Documents
Culture Documents
DEMO
Multi
Dimensional
Jagged
Arrays
ReDim Preserve [VB.Net]
ReDim: Reallocate storage space for an array variable.
Preserve: Preserve the data in the existing array when you change the size of only the last dimension.
DEMO
Iteration Statements
do
Reading Arrays using foreach
for
C# provides simple and straightforward ways to initialize arrays at declaration time by enclosing the initial values in curly
foreach, in
braces ({}). The following examples show different ways to initialize different kinds of arrays.
while
Single
Dimensional
Multi
Dimensional
Jagged
Try yourself!!
DEMO
Collections Class
do
Using foreach with collection class
for
foreach, in
The foreach statement is a convenient way to enumerate the elements of a collection, provided that the
collection class has implemented the System.Collections.IEnumerator and System.Collections.IEnumerable
while
interfaces.
The below example (class diagram) – shows the implementation of a string tokenizer.
enumeration is referred
to listing the elements of
a collection.
Collections Class
do
Using foreach with collection class
for
foreach, in
The below example (class diagram) – shows the implementation of a string tokenizer.
while
DEM
O
Jump Statements
break
C#.Net VB.Net
continue
goto
Branching is performed using jump statements, which cause an immediate transfer of the program control.
return break Terminates the closest enclosing loop
DEMO
throw continue Passes control to the next iteration of the enclosing iteration statement in which it appears.
return Terminates execution of the method in which it appears and returns control to the calling method.
throw Used to signal the occurrence of an anomalous situation (exception) during the program execution.
Exception Overview
System.Exception Overview
C# provides built-in support for handling anomalous situations, known as exceptions, which may occur
during the execution of your program.
System.Exception class represents errors that occur during application execution.
C# VB.Net
DEMO