Maha EL-basuony OOP
Jan 19, 2015
Maha EL-basuonyOOP
Agenda
Array
Functions
OOP
Type [ ] Array_Name = new int [arraySize] ;
Array
int[] myIntArray = {5, 9, 10, 2, 99} ;
int[] myIntArray = new int[5] ;
int[] myIntArray = new int[5] {5, 9, 10, 2, 99} ;
Examples
One Dimensional Array
a data structure that contains several variables of the same type .
Multidimensional Arrays
- A two - dimensional array such as this is declared as follows :
< baseType > [ , ] < name >
double[ , ] hillHeight = new double[3,4] ;
int[ , ] hillHeight = {{1, 2, 3, 4}, {2, 3, 4, 5}, {3, 4, 5, 6}} ;
Examples
Arrays of Arrays
int[][] MyArray ;MyArray = {{1, 2, 3}, {1}, {1, 2}} ;
int[][] MyArray = {new int[] {1, 2, 3}, new int[] {1}, new int[]{1,2}} ;
MyArray = new int[2];][MyArray[0] = new int[3];MyArray[1] = new int[4] ;
MyArray= new int[3][] {new int[] {1, 2, 3}, new int[] {1},new int[] {1, 2}} ;
String Manipulation
String Builder
Array List
Queue
Functions
static Void < functionName) ( > { ... }
static < returnType > < functionName ) ( > {...
return < returnValue > }
Value Parameters
Reference Parameters
Out Parameters
Main Function
static void Main) (
static void Main(string[] args)
static int Main)(
static String Main(string[] args)
Struct Function
Overloading Functions
create multiple functions with the same name, but each working with different parameter types
Generic
Delegates
A delegate is a type that enables you to store references to functions.
try {
// the code that might has exception }
catch {
// exception handling block }
finally{
// this block is executed either there is exceptions or not
}
try . . . catch . . . finally
Classes & Objects
Constructors
This
Access Modifier
-Public Members are accessible from any code.
-Private Members are accessible only from code that is part of the class (the default if no keyword is used) .
-Protected Members are accessible only from code that is part of either the class or a derived class.
-Internal Members are accessible only from code within the project (assembly) where they are defined .
-Protected Internal These are only accessible from code - derived classes within the project (more accurately, the assembly).
Class Definition
Encapsulation
Inheritance is -a
has -a
tire is a car
car has a tire
has -a
Interface
-like a class, but has no implementation.
-Can be Internal or Public
Polymorphism
Future Sessions
System.IO
System.Linq
System.Threading
Q & AThanks