Encapsulation definition with example in C#.Net

Encapsulation definition with example

which is nothing but wrapping up of code and data. Here code is function and data is attributes. This approach will reduce the relationship between the objects as well give access to maintainability of the code.

Below table show how can we able to connectivity to the other objects.

This is one of the good OOPS DOTNET Interview Question.

Access ModifierDescription (access information)
privateOnly for with in the same type. These are default for all types (int, string,...)
protectedIf we use inheritence only derived types call access of base type
internalwe can accesses with in the assembly. 
protected internalthis is combination of protected and internal. 
publicwe can access any where. 

using System;

class BankAccountDetails
    private string m_CustName;

    public string bankCustName
        get { return  m_CustName ; }
        set {  m_CustName  = value; }

In this example. we are hiding the string bankCustName to the other object. 

See more OOPS DOTNET Interview Questions

See more ASP.NET, C#.NET, SQL Server and more Interview Questions

Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar