Oops concept
Oops concept
we need to expose what is necessary and compulsory and we need to hide the unnecessary things from
the outside world. In C# we can hide the member of a class by using private access modifiers.
Encapsulation:
Hiding complexity
Encapsulation help us to make our class simpler to use or make our object to simpler to use.
Access modifier:
Private: Only member of class have access. Any external member can’t have access this faction.
Public: All the member have access in all class and projects.
Protected: All member have access in current class and derived class can access the variables.
Protected internal: All member in the current project and all member in the derived class access in the
variable.
Abstract class:
1. Cannot create an instance of the abstract class or interface
2. Abstract class define the method but can’t define the body.
4. A class can’t inherit from more than one class for the same time but class can inherit
from the more than one interface at the same time.
5. Can a class implementation interface with same method name?
Answer: Yes, to define two different implementations for same method name we need to use explicit
interface method implementation.
Polymorphism:
Definition: Polymorphism is basically allows you to invoked derived class methods through base class
reference variables at run time that’s polymorphism.
Definition: Polymorphism is sharing a common interface for multiple types but having different
implementation for different types.
Operator Overloading
Definition: Operator overloading gives the ability to use the same operator to do various operations.
Delegates
Definition: A delegate is a type-safe function pointer that can reference a method that has the same
signature as that of the delegate.
Generic Delegates
1. Func - It takes one or more input parameters and returns one out parameter.
Action action1=DelegateClass.ShowEmploye;
action1(30,"Rajesh");
3. Predicate - one input parameter and one Boolean return type either true or false.
Anonymous Method
Is a method without having name. The anonymous methods in c# can be defined using keyword
delegates and can assign to variable of the delegates’ type.