Dec 16, 2019

ENCAPSULATION IN C#

c# encapsulation, c# programming, encapsulation examples
encapsulation in c#

  We are going to make our software or application where we need to show some of our program function or features to user and some will be hide and will show when require arise.  This type of works can be done by creating our program features public and private or protected, this phenomenon is known as Encapsulation.
Definition:
            “The mechanism of showing and hiding of our class member from outside of world or class as needed is called Encapsulation.”
            We can apply Encapsulation by following methods.
1.    Public members
2.    Private members
3.    Protected members
4.    Internal members
5.    Protected internal members

PUBLIC MEMBERS

            All the normal class members, we are creating as a public member.  The definition can be “all the member that can be accessible from, outside of class is called public member.” It created with the keyword name public such as, public void name( ).
SYNTAX
Public void Name ( )
{
   Statement;
}

PRIVATE MEMBERS

            “Private members are those members that cannot accessible form outside of class. Instead of Object instantiate of class.“ it created by following the keyword private before the class member where as if there is no mention of private or public then we will considered as private.
SYNTAX      
Private void Name ( )
{
Statement
}

PROTECTED MEMBERS

            “Protected members are those members that can access only its child class by instantiation object in child class”. The process of inheritance takes place to these members.
SYNTAX
Public Class Parent
{
Members;
{
Public class Child: Parent
{
Parent Obj =new Parent ( );
Obj.
Statement:
}

INTERNAL MEMBERS

”Members that pre-defined in the Assembly or namespace of compiler is known as internal members. These members can be called in any class by instantiating its object.”
SUCH AS, Using system. IO;

PROTECTED INTERNAL MEMBERS

            “Protected internal members are those members which is accessible from outside of assemblies or in a single project among its assembly reference”.

See examples:   click here



1 comment:

Please do not enter any spam link in the comment box