1 / 36

C# Programming

C# Programming. Fundamentals of Object-Oriented Programming Introducing Microsoft .NET Overview of C# Using Value-Type variables Statements and Exceptions Methods and Parameters Strings Arrays and Collections C# and Object Oriented Programming Using Reference-Type Variables

Download Presentation

C# Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C# Programming • Fundamentals of Object-Oriented Programming • Introducing Microsoft .NET • Overview of C# • Using Value-Type variables • Statements and Exceptions • Methods and Parameters • Strings Arrays and Collections • C# and Object Oriented Programming • Using Reference-Type Variables • Creating and Destroying Objects • inheritance in C# • Aggregations, Namespaces and Advance Scope • Operators, Delegates and Events • Properties and Indexers

  2. Fundamentals of Object-Oriented Programming • What is OOP • Objects vs. Classes • Instantiation • Encapsulation • Inheritance • Polymorphism

  3. What is OOP • Object-oriented programming (OOP) is 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 relate to each other

  4. Objects vs. Classes Object MyHouseAn Instance of HouseOfFun Class HouseOfFunA blue print of the HouseOfFun house. Object MyHouseAn Instance of HouseOfFun Object YelloHouse[0]An Instance of HouseOfFun Object YelloHouse[1]An Instance of HouseOfFun

  5. Objects vs. Classes public class HouseOfFun { public HouseOfFun(string city, int rooms, int buildYear) { this.city = city; this.rooms = rooms; this.buildYear = buildYear; } protected string city; protected int rooms; protected int buildYear; public int calcHouseAge() { // calculationjust for this sample return (DateTime.Now.Year - buildYear); } }

  6. Instantiation class mainClass { static void Main( ) { HouseOfFun myHouse = new HouseOfFun("Tel Aviv",2,1963); Console.WriteLine(myHouse.calcHouseAge()); } }

  7. Encapsulation • The ability of an object to hide its internal data and methods, making only the intended parts of the object programmatically accessible. • C# • Public • Private • protected

  8. Inheritance • 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).

  9. Polymorphism • 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.

  10. Encapsulation, Inheritance, Polymorphism Sample page 1/3: class with virtual method class Teacher { public Teacher(string firstName,string lastName,int practiceYears,double payRate) { this.firstName = firstName; this.lastName = lastName; this.practiceYears = practiceYears; this.payRate = payRate; } protected string firstName; protected string lastName; protected int practiceYears; protected double payRate; public virtual double CalculatePayment(int hourseWorked) { // do something return 1,000,000.00; // bogus value } }

  11. Encapsulation, Inheritance, Polymorphism - 2/3FullTimeTeacher is derived from Teacher • class FullTimeTeacher:Teacher • { • public FullTimeTeacher(string firstName,string lastName,int practiceYears,double payRate) • :base (firstName,lastName, practiceYears,payRate) • { • } • public override double CalculatePayment(int hourseWorked) • { //do something • } • } • class PartTimeTeacher:Teacher • { • public FullTimeTeacher(string firstName,string lastName,int practiceYears,double payRate) • :base (firstName,lastName, practiceYears,payRate) • { • } • public override double CalculatePayment(int hourseWorked) • { //do something • } • }

  12. Encapsulation, Inheritance, Polymorphism 3/3- teachers group hold FullTimeTeacher & PartTimeTeacher - CalculatePayment code stays the same class PolymorphismSample { protected Teacher[] teachers; protected void LoadTeachers() { //in a real world situation we will use the database teachers = new Teacher[2]; teachers[0] = new FullTimeTeacher("Marta", "Kohen", 25, 2500.00); teachers[2] = new PartTimeTeacher("Bar", "Shalom", 40, 50.00); } protected void CalculatePayment() { foreach(Teacher tcr in teachers) { tcr.CalculatePayment(40); } } }

  13. Introducing Microsoft .NET • The .NET Framework • The Common Language Runtime • The .NET Framework Class Libraries • Microsoft Intermediate Language and the Jitters • Unified Type System • Metadata and Reflection

  14. The .NET Framework ASP.NET Windows Forms Data and XML Base Classes Common Language Runtime

  15. The Common Language Runtime Common Type System Intermediate Language to Native Code Compilers ExecutionSupport Security GC, Stack Walk, Code Manager Class Loader & Memory Layout

  16. The .NET Framework Class Libraries .Net Class Libraries provides language interoperability. Sample: The Class shown in this class Browser System.Data.OleDb.OleDbConnection can be used by all the many .Net languages

  17. Microsoft Intermediate Language and the Jitters

  18. Unified Type System

  19. Metadata and Reflection

  20. Overview of C# • Structure of a c# program • Basic Input/Output Operations • Recommended Practices • Compiling Running and Debugging

  21. Using Value-Type variables • Common Type System • Naming Variables • Using Built-in Data Types • Compound Assignment • Increment and Decrement • Creating User Defined Data Types • Converting Data Types

  22. Statements and Exceptions • Selection Statements • Iteration Statements • Jump Statements • Handling Basic Exceptions • Raising Exceptions

  23. Methods and Parameters • Methods • Parameters • Overload Methods

  24. Strings Arrays and Collections • Strings • Creating Arrays • Using Arrays • Collections • .NET Framework Arrays • .Net Framework Collections • working with Strings, Enumerators and Collections

  25. C# and Object Oriented Programming • Creating and using Classes

  26. Using Reference-Type Variables • Reference-Type Variables • Common Reference Types • The Object Hierarchy • Namespaces in the .Net Framework • Data Conversions • Type-Safe Casting

  27. Creating and Destroying Objects • Constructors • Initializing Data • Objects and Memory • Destructors

  28. inheritance in C# • Deriving Classes • Implementing Methods • Sealed Classes • Interfaces • Abstract Classes

  29. Aggregations, Namespaces and Advance Scope • Using internal classes, Methods and Data • Using Aggregation • Using Namespaces • Using Modules and Assemblies

  30. Operators, Delegates and Events • Operators • Operator Overloading • Delegates • Events • When to use Delegates, Events and Interfaces

  31. Properties and Indexers • properties • Indexers

  32. Review

  33. C# Advance • Attributes • The SDK Tools

  34. Attributes • Overview of attributes • Defining Custom Attributes • Retrieving Attributes Values

  35. The SDK Tools • Configuration and Deployment Tools • Debugging Tools • Security Tools and Utilities • General Tools

  36. Review

More Related