C# Fundamentals - Basics of OOPS

Page 1

iFour Consultancy Basics of OOPS

https://www.ifourtechnolab.com/microsoft-technology


Definition

•A markup language is a set of markup tags •A markup language is a set of markup tags

 Programming language model organized around objects rather than "actions" and data

rather than “logic”. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data  For a programming language to be a true OOP language, the language must meet the following criteria:    

Abstraction Encapsulation Polymorphism Inheritance

https://www.ifourtechnolab.com/microsoft-technology


Fundamentals  Classes and Objects 

The terms class and object are sometimes used interchangeably, but in fact, classes describe the type of objects, while objects are usable instances of classes. So, the act of creating an object is called instantiation. Using the blueprint analogy, a class is a blueprint, and an object is a building made from that blueprint

 Abstraction 

Abstraction manages the complexities of a business problem by allowing you to identify a set of objects involved with that business problem

 Encapsulation 

Encapsulation hides the internal implementation of an abstraction within the particular object

 Polymorphism 

It provides for multiple implementations of the same method. For example, different objects can have a Save method, each of which perform different processing

 Inheritance  The

excitement of Visual Basic .NET lies in inheritance. Visual Basic 5 introduced the concept of interface inheritance, which allows you to reuse the interface of a class, but not its implementation

https://www.ifourtechnolab.com/microsoft-technology


What is a class? ďƒ˜ It can be defined as a template/blueprint that describes the behaviors/states that object

of its type support ďƒ˜ Example of simple class with member properties and member methods. public class Circle { private decimal _radius; public double radius {get{return _radius;} set{_radius = values} } public double Area() { return 3.141592 * _radius * _radius; } } https://www.ifourtechnolab.com/microsoft-technology


What is Object?  It represents a particular instance of a class. There can be more than one instance of an

object. Each instance of an object can hold its own relevant data  Example of Simple instantiate of an object of the class in the example of previous slides Circle objCircle = new Circle(); //here objCircle is an instance of a class Circle objCir = new Circle(); //here objCir is an instance of a class

 Both the instantiation(Objects) holds the related data and members of the class and can

be used for different purposes

https://www.ifourtechnolab.com/microsoft-technology


Abstraction  Example  Real world example “Laptop”  When derived class inherited with abstract class; derived class must be override abstract class methods

https://www.ifourtechnolab.com/microsoft-technology


Encapsulation  Hiding irrelevant data from the user  A class may contain much information that is not useful for an outside class or interface  So classes use encapsulation to hide its members that are not relevant for an outside

class or interface  It can be done using access specifiers 

In the same example of Circle class “Private” is a specifier used for Member variable. So It hides the data to be used outside the class:

private decimal _radius;

https://www.ifourtechnolab.com/microsoft-technology


Inheritance  Use in the small, when a derived class "is-a" base class  

enables code reuse enables design reuse & polymorphic programming

 Example: 

a Student is-a Person Person

Student Undergraduate

Employee

Graduate

Staff

Faculty

https://www.ifourtechnolab.com/microsoft-technology


Inherited Methods

https://www.ifourtechnolab.com/microsoft-technology


Inherited Methods

https://www.ifourtechnolab.com/microsoft-technology


Polymorphism  Static polymorphism  Function overloading  Operator overloading

 Dynamic Polymorphism  abstract classes  virtual functions

https://www.ifourtechnolab.com/microsoft-technology


Virtual and Overridden Methods

https://www.ifourtechnolab.com/microsoft-technology


Combining Method Overriding and Hiding

https://www.ifourtechnolab.com/microsoft-technology


Procedure v/s Object Oriented Programming  It is a methodology to write the program where we specify the code in form of classes and

objects  Object-oriented programming is the successor of procedural (structural) programming  Procedural programming describes programs as groups of reusable code units (procedures) which define input and output parameters. Procedural programs consist of procedures, which invoke each other  The problem with procedural programming is that code reusability is hard and limited – only procedures can be reused and it is hard to make them generic and flexible.  There is no easy way to work with abstract data structures with different implementations  This is how objects came to be. They describe characteristics (properties) and behaviour (methods) of such real life entities https://www.ifourtechnolab.com/microsoft-technology


Interface  Multiple Inheritance Support  Example: 

SmartPhone  OS()  AppStore()

https://www.ifourtechnolab.com/microsoft-technology


References  https://www.tutorialspoint.com/csharp/  http://www.c-sharpcorner.com/UploadFile/mkagrahari/introduction-to-object-oriented-

programming-concepts-in-C-Sharp/

https://www.ifourtechnolab.com/microsoft-technology


Thank You..

https://www.ifourtechnolab.com/microsoft-technology


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.