Unusual C#OOP GatePrepared & Presented by:Eng. : Medhat Dawoud
Relax your self
Let your imaginations
I want you to know that we are learning :
Actually it’s Usual C#
General OverviewWhat is OOP ?What is class?Difference between class and object.The life cycle of an object:Construction DestructionThe accessibility.Static Vs Instance.Reference type Vs. Value type.OOP techniques.
What is OOP ?The difference between :Object Oriented Programming andProcedure Oriented Programming.Object Oriented Programming, why?
A real example : car manufacturing.
What is OOP ?The difference between :Object Oriented Programming andProcedure Oriented Programming.Object Oriented Programming, why?
A real example : car manufacturing. What is class?Class is a great container .Has some members like : (constructor, properties, fields, Methods, Variables, statements, …).It has some features which are given to its instances.Class like : Department
Difference between class and object:What is an object ?object is a building block of an OOP application, this building block encapsulates part of the application.Objects are created from types, these types of an object is known by classes.The object is an instance of a class.We treat with classes through objects.“every thing is object”
The life cycle of an object:The object has three cases:Construction.Default constructor is often public.What if it become private? Being in use.Destruction.
The accessibilityDetermine which code can access these members that is whether they are available to all code ( public ) or only to code within the class ( private ).The modifier ( protected ).We can make fields privates and provide access to them via public properties.(the encapsulation)
Static Vs InstanceStatic members are shared between instances of the class.When using static members you needn’t to instantiate an object.To use Instance members you must instantiate an object from the class.
Reference type Vs Value type
OOP techniquesEncapsulation.Abstract.Interface.Inheritance.Polymorphism.
EncapsulationMaking fields privates and provide access to them via public properties.Classes Idea is encapsulation.Why encapsulation ?
AbstractAbstract class is a class that may or may not contain abstract methods.Abstract class can’t be instantiated.An abstract method is a method that is declared without an implementation.If a class includes abstract methods, the class itself must be declared abstract.
 Interface If an abstract class contains only abstract method declarations, it should be declared as an interface instead.Interface can’t be instantiated.You can implement interface in an inherited class.Imagine the interface as a contract between interface creator and class consumers.
InheritanceChild class inherited from (derived from) parent class (base class).In C#, you may derive only from a single base class directly.You can override a member in child class that is virtual in the parent class.A class may be sealed.C# provide a common base class for all objects called object.
PolymorphismIt is very useful for performing tasks with a minimum of code on different objects from a single class.Overriding & Overloading.Polymorphism means that : you can use the same instruction with different return value into screen.
Practice
Any Questions ?I have some questions !!
Can you allow class to be inherited, but prevent the method from being over-ridden?Yes, just leave the class public and make the method sealed.
Can you override private virtual methods?No, you cannot access private methods in inherited classes.
Can you declare the override method static while the original method is non-static?No, you can't, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override
The last question..Is it true or false , and why ?False , Because its constructor is private 
Contact me for any inquiryMedhatDawoud[at]Gmail.com ..E-mail me..twitter.com/Med7atDawoud ..follow me..Med7at.wordpress.com ..Current Blog..www.MedhatDawoud.com..Coming soon.. 
Thanks for listening

Unusual C# - OOP

  • 1.
    Unusual C#OOP GatePrepared& Presented by:Eng. : Medhat Dawoud
  • 2.
  • 3.
  • 4.
    I want youto know that we are learning :
  • 5.
  • 6.
    General OverviewWhat isOOP ?What is class?Difference between class and object.The life cycle of an object:Construction DestructionThe accessibility.Static Vs Instance.Reference type Vs. Value type.OOP techniques.
  • 7.
    What is OOP?The difference between :Object Oriented Programming andProcedure Oriented Programming.Object Oriented Programming, why?
  • 8.
    A real example: car manufacturing.
  • 9.
    What is OOP?The difference between :Object Oriented Programming andProcedure Oriented Programming.Object Oriented Programming, why?
  • 10.
    A real example: car manufacturing. What is class?Class is a great container .Has some members like : (constructor, properties, fields, Methods, Variables, statements, …).It has some features which are given to its instances.Class like : Department
  • 11.
    Difference between classand object:What is an object ?object is a building block of an OOP application, this building block encapsulates part of the application.Objects are created from types, these types of an object is known by classes.The object is an instance of a class.We treat with classes through objects.“every thing is object”
  • 12.
    The life cycleof an object:The object has three cases:Construction.Default constructor is often public.What if it become private? Being in use.Destruction.
  • 13.
    The accessibilityDetermine whichcode can access these members that is whether they are available to all code ( public ) or only to code within the class ( private ).The modifier ( protected ).We can make fields privates and provide access to them via public properties.(the encapsulation)
  • 14.
    Static Vs InstanceStaticmembers are shared between instances of the class.When using static members you needn’t to instantiate an object.To use Instance members you must instantiate an object from the class.
  • 15.
  • 16.
  • 17.
    EncapsulationMaking fields privatesand provide access to them via public properties.Classes Idea is encapsulation.Why encapsulation ?
  • 18.
    AbstractAbstract class isa class that may or may not contain abstract methods.Abstract class can’t be instantiated.An abstract method is a method that is declared without an implementation.If a class includes abstract methods, the class itself must be declared abstract.
  • 19.
    Interface If anabstract class contains only abstract method declarations, it should be declared as an interface instead.Interface can’t be instantiated.You can implement interface in an inherited class.Imagine the interface as a contract between interface creator and class consumers.
  • 20.
    InheritanceChild class inheritedfrom (derived from) parent class (base class).In C#, you may derive only from a single base class directly.You can override a member in child class that is virtual in the parent class.A class may be sealed.C# provide a common base class for all objects called object.
  • 21.
    PolymorphismIt is veryuseful for performing tasks with a minimum of code on different objects from a single class.Overriding & Overloading.Polymorphism means that : you can use the same instruction with different return value into screen.
  • 22.
  • 23.
    Any Questions ?Ihave some questions !!
  • 24.
    Can you allowclass to be inherited, but prevent the method from being over-ridden?Yes, just leave the class public and make the method sealed.
  • 25.
    Can you overrideprivate virtual methods?No, you cannot access private methods in inherited classes.
  • 26.
    Can you declarethe override method static while the original method is non-static?No, you can't, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override
  • 27.
    The last question..Isit true or false , and why ?False , Because its constructor is private 
  • 28.
    Contact me forany inquiryMedhatDawoud[at]Gmail.com ..E-mail me..twitter.com/Med7atDawoud ..follow me..Med7at.wordpress.com ..Current Blog..www.MedhatDawoud.com..Coming soon.. 
  • 29.