08 Encapsulation Concept in C# | Object Oriented Programming in C# | Basic to Advance Level
Channel: Masood Tech
Date: 2020-02-16

Subscribe Us For More Info  @Masood Tech  
Object-Oriented Programming (C#):
C# provides full support for object-oriented programming including encapsulation, inheritance, and polymorphism. 

Encapsulation means that a group of related properties, methods, and other members are treated as a single unit or object.
Inheritance describes the ability to create new classes based on an existing class.

Polymorphism means that you can have multiple classes that can be used interchangeably, even though each class implements the same properties or methods in different ways.

This section describes the following concepts:
-Classes and Objects
-Class Members
-Properties and Fields
-Methods
-Constructors
-Finalizers
-Events
-Nested Classes
-Access Modifiers and Access Levels
-Instantiating Classes
-Static Classes and Members
-Anonymous Types
-Inheritance
-Overriding Members
-Interfaces
-Generics
-Delegates

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.

Class Members:
Each class can have different class members that include properties that describe class data, methods that define class behavior, and events that provide communication between different classes and objects.

Properties and Fields:
Fields and properties represent information that an object contains. Fields are like variables because they can be read or set directly.
Properties have get and set procedures, which provide more control on how values are set or returned.

C# allows you either to create a private field for storing the property value or use so-called auto-implemented properties that create this field automatically behind the scenes and provide the basic logic for the property procedures.

Methods:
A method is an action that an object can perform.
A class can have several implementations, or overloads, of the same method that differ in the number of parameters or parameter types.
In most cases you declare a method within a class definition. However, C# also supports extension methods that allow you to add methods to an existing class outside the actual definition of the class.

Static Object in C#:
In C#, one is allowed to create a static class, by using static keyword. A static class can only contain static data members, static methods, and a static constructor.It is not allowed to create objects of the static class. Static classes are sealed, means you cannot inherit a static class from another class.

Passing Class as Datatype: 
A value-type variable contains its data directly as opposed to a reference-type variable, which contains a reference to its data. Passing a value-type variable to a method by value means passing a copy of the variable to the method. Any changes to the parameter that take place inside the method have no affect on the original data stored in the argument variable. If you want the called method to change the value of the argument, you must pass it by reference, using the ref or out keyword. You may also use the in keyword to pass a value parameter by reference to avoid the copy while guaranteeing that the value will not be changed. For simplicity, the following examples use ref.

Inheritance Concept In C#:
Inheritance is an important concept in C#. Inheritance is a concept in which you define parent classes and child classes. The child classes inherit methods and properties of the parent class, but at the same time, they can also modify the behavior of the methods if required.

Prerequisites:
Namspace and functions

All the rest you need to know about C# is there.

Alim Ul Karim
Works for Developers Organism (http://developers-organism.com) 
http://fb.com/DevelopersOrganism
Blog: http://auk-port.blogspot.com/
Portfolio: http://auk-port.zxq.net/
mail to: info {at} developers-organism.com
mail to: alim {at} developers-organism.com

Sildes PDF:
http://bit.ly/S98oxO
Coding:
http://bit.ly/S98t4O or http://bit.ly/1k7Dh3a or  https://github.com/aukgit/Object-Orie...