Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
20 views

C# and Object Oriented Programming

Uploaded by

sagidih06928
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
20 views

C# and Object Oriented Programming

Uploaded by

sagidih06928
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 36
Fundamentals of Object-Oriented Programming, Tntroducing Microsoft .NET LO ea Cia Using Value-Type variables BSE Ueoseel as LicinseW Bs cere le(e ats Methods and Parameters SSIs ets a Cre NE Tes Oke) Cat Ceoety C# and Object Oriented Programming Using Reference-Type Variables Creating and Destroying Objects Te tovie tate bok Oia Aggregations, Namespaces and Advance Scope Operators, Delegates and Events Properties and Indexers = What is OOP = Objects vs. Classes = Instantiation = Encapsulation = Inheritance = Polymorphism = Object-oriented programming (OOP) ts a programming language model organized around "objects" rather than "actions" and data rather than logic. = The first step in OOP is to identify all the objects you want to manipulate and how they Ror ItemKene (a molieca Cea ige ee PEN mee) Class HouseOfFun ah a Ce ee mee) oa uy, , Object YelloHouse{0] ee) ed Object YelloHouse[1] An Instance of HouseOfFun Objects vs. Classes public class HouseOfFur public HouseOfFun(string city, int rooms, int build Year this.city = city this. ms = rooms: this buildYear = buildYear protected string cit protected int rooms; protected int buildYear; public int calcHouseAg calculation just for this sample return (DateTime.Now:Year - buildYear Instantiation class mainClass static void Main() HouseOfFun("Tel Aviv = The ability of an object to hide its internal data and methods, making only the intended parts of the object programmatically accessible. LC 2 = Public DR eenrie LM exenccanees = Subclass that is defined can inherit the definitions of one or more general classes. = An object in a subclass need not carry generic definition of data and methods = speeds up program development; = ensures an inherent validity (what works and is consistent about the class will also work for the subclass). = Polymorphism gives you the ability to group objects that have a common base class and treat them consistently. = Polymorphism allows you to extend or enhance your system without modifying or breaking existing code. Encapsulation, Inheritance, Polymorphism Sample page 1/3: class with virtual method class Teacher i t public Teacher(string firstName,string lastName,int practice Years,double payRate) ‘ t firstName; this.lastName = lastName; this.practiceYears = practiceYears; Rate; this.payRate = pa protected string firstName; tName; protected int practiceYears; protected double payRate; protected string | public virtual double CalculatePayment(int hourseWorked) ‘ t // do something return 1,000,000.00; / bogus value Encapsulation, Inheritance, Polymorphism - 2/3 FullTimeTeacher is derived from Teacher class FullTimeTeacher:Teacher { public FullTimeTeacher(string firstName,string lastName,int practice Years,double payRate) tbase (firstName,lastName, practice Years,payRate) } } public override double CalculatePayment(int hourseWorked) { //do something } 5 1 i class PartTimeTeacher:Teacher public FullTimeTeacher(string firstName,string lastName,int practice Years,double payRate) tbase (firstName,lastName, practiceYears,payRate) public override double CalculatePayment(int hourseWorked) { //do something ncapsulation, Inheritance, Polymorphism 3/3 - teachers group hold FullTimeTeacher & PartTimeTeacher - CalculatePayment code stays the same class PolymorphismSampk protected Teacher[] teachers protected void LoadTeache 1a real world situation we will use the databas teachers = new Teacher[2 teachers[0] = new FullTimeTeacher("Marta", "Kohen", 25, 2500.00 teachers[2] = new PartTimeTeacher "Shalom", 40, 50.0 protected void CalculatePayment foreach(Teacher tcr in teachers) cr.CalculatePayment(40) = The .NET Framework = The Common Language Runtime Ue NES aco Vona Ore Ble te(c = Microsoft Intermediate Language and the Jitters = Unified Type System = Metadata and Reflection ASP.NET Windows Forms Data and XML SERIO EI Common Language Runtime Common Type System Intermediate Language oD e-sainel Cert Native Code Compilers bel te GC, Stack Walk, Code Manager Class Loader & Memory Layout The .NET Framework Class Libraries J Matric CassBrowser -Net Class Libraries Peaustoner provides language “J Syrian Date OlDb OleDbConnection al PC Cou oe aiiag ly eget public Seng] Conneetionstring { Foccomerdoasecentgustestrtate OleDbConnection oriented: < > the many Net ar arnme 100% [MEO BOL a0 m Structure of a c# program = Basic Input/Output Operations = Recommended Practices = Compiling Running and Debugging = Common ‘Type System = Naming Variables = Using Built-in Data Types = Compound Assignment = Increment and Decrement = Creating User Defined Data Types = Converting Data ‘Types a Selection Statements m Iteration Statements = Jump Statements = Handling Basic Exceptions = Raising Exceptions = Methods = Parameters = Overload Methods Dsieebeteas = Creating Arrays = Using Arrays Lo) lKeretefoxery = .NET Framework Arrays = .Net Framework Collections = working with Strings, Enumerators and Collections = Creating and using Classes = Reference-Type Variables = Common Reference Types = The Object Hierarchy = Namespaces in the .Net Framework = Data Conversions = Type-Safe Casting = Constructors m= Initializing Data = Objects and Memory = Destructors EB Bonv sea Ores) = Implementing Methods = Sealed Classes LB beleourlacs = Abstract Classes = Using internal classes, Methods and Data = Using Aggregation m Using Namespaces = Using Modules and Assemblies = Operators = Operator Overloading PB Bra lee-tres LI Ba cele = When to use Delegates, Events and Interfaces L etcoyrodntesy = Indexers = Attributes = The SDK Tools = Overview of attributes = Defining Custom Attributes = Retrieving Attributes Values = Configuration and Deployment ‘Tools = Debugging Tools = Security Tools and Utilities = General Tools

You might also like