3. Object-oriented programming
Programming languages designed based on data and ways to
manipulate data.
Procedural Languages (Pascal, C) focus on ways
Object-oriented Languages (C#, Java) focus on data
4. Features
Abstraction
Encapsulation
Inheritance
Polymorphism
Focus only the required information from objects
5. Features
Abstraction
Encapsulation
Inheritance
Polymorphism
Hide details of what a class contains
6. Features
Abstraction
Encapsulation
Inheritance
Polymorphism
Create a new class based on the attributes
and methods of an existing class
7. Features
Abstraction
Encapsulation
Inheritance
Polymorphism
Behave differently in different situations
9. Class – should & cannot
Should
be a noun
first letter capitalized
simple, descriptive, meaningful
Cannot
in mixed case
C# keyword
begin with a digit except @, _
13. Static methods
called without creating any objects of the class
refer only to static variables and other static methods of class.
https://gist.github.com/2349658
14. Static methods
Only one copy of static variable is shared by all the objects of the
class.
21. Method overloading
every method has a signature which comprises
the number of params
the data types of params
the order of params
22. Should and avoid
Methods to be overloaded should perform the same task
The signatures of the overloaded must be unique
Return type is not a part of the signature
The ref and out parameters can be included as a part of the
signature
23. This keyword
refer to the current object of the class.
cannot use this keyword with static variables and method
https://gist.github.com/2344534
26. Constructors
initialization
no return type
possible to have overloaded constructors
https://gist.github.com/2344570
27. Default Constructors
C# creates a default constructors for a class if no constructor is
specified within the class. It automatically initializes all the numeric
data type instance variables to zero.
If you define a constructor in the class, the default constructor is no
longer used.
28. Static Constructors
initialize static variables of the class and to perform a particular
action only once.
is invoked before any static member of the class is accessed.
does not take any parameters and does not use any access modifiers
because it is invoked directly by the CLR instead of the object.
Certainly, cannot access non-static data member.
https://gist.github.com/2344643
30. Destructors
invoked automatically when the objects are not in use
only one destructor in a class
cannot be overloaded or inherited
cannot be explicitly invoked
cannot specify access modifiers and cannot take parameters
https://gist.github.com/2344708