Top Banner
Maha EL-basuony OOP
52
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: OOP in C#

Maha EL-basuonyOOP

Page 2: OOP in C#

Agenda

Array

Functions

OOP

Page 3: OOP in C#

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 .

Page 4: OOP in C#
Page 5: OOP in C#

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

Page 6: OOP in C#
Page 7: OOP in C#

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}} ;

Page 8: OOP in C#
Page 9: OOP in C#

String Manipulation

Page 10: OOP in C#

String Builder

Page 11: OOP in C#

Array List

Page 12: OOP in C#

Queue

Page 13: OOP in C#
Page 14: OOP in C#

Functions

static Void < functionName) ( > { ... }

static < returnType > < functionName ) ( > {...

return < returnValue > }

Page 15: OOP in C#
Page 16: OOP in C#
Page 17: OOP in C#
Page 18: OOP in C#

Value Parameters

Page 19: OOP in C#

Reference Parameters

Page 20: OOP in C#

Out Parameters

Page 21: OOP in C#

Main Function

static void Main) (

static void Main(string[] args)

static int Main)(

static String Main(string[] args)

Page 22: OOP in C#
Page 23: OOP in C#
Page 24: OOP in C#

Struct Function

Page 25: OOP in C#

Overloading Functions

create multiple functions with the same name, but each working with different parameter types

Page 26: OOP in C#

Generic

Page 27: OOP in C#

Delegates

A delegate is a type that enables you to store references to functions.

Page 28: OOP in C#
Page 29: OOP in C#

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

Page 30: OOP in C#
Page 31: OOP in C#

Classes & Objects

Page 32: OOP in C#

Constructors

Page 33: OOP in C#

This

Page 34: OOP in C#

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).

Page 35: OOP in C#

Class Definition

Page 36: OOP in C#
Page 37: OOP in C#
Page 38: OOP in C#
Page 39: OOP in C#

Encapsulation

Page 40: OOP in C#
Page 41: OOP in C#

Inheritance is -a

Page 42: OOP in C#

has -a

Page 43: OOP in C#

tire is a car

car has a tire

has -a

Page 44: OOP in C#
Page 45: OOP in C#
Page 46: OOP in C#

Interface

-like a class, but has no implementation.

-Can be Internal or Public

Page 47: OOP in C#
Page 48: OOP in C#
Page 49: OOP in C#
Page 50: OOP in C#

Polymorphism

Page 51: OOP in C#

Future Sessions

System.IO

System.Linq

System.Threading

Page 52: OOP in C#

Q & AThanks