top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Define Data Encapsulation in c# ?

+3 votes
277 views

Hai friends anybody say about the Data Encapsulation in C#

posted Nov 19, 2014 by Roshan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

Data Encapsulation is defined as the process of hiding the important fields from the end user. In the above example , we had used getters and setters to set value for MinSalary. Idea behind this is that , private field “minimumSalary” is an important part of our classes. So if we give a third party code to have complete control over the field without any validation it can adversely affect the functionality. This is in line with OOPS Concept that an external user should know about the what an object does. How it does it should be decided by the program. So if a user set a negative value for MinSalary , we can put a validation in set method to avoid negative values as shown below

set
{
if(value > 0)
{
minSalary = value;
}}
answer Nov 19, 2014 by Manikandan J
+1 vote

Encapsulation is defined 'as the process of enclosing one or more items within a physical or logical package'. Encapsulation, in object oriented programming methodology, prevents access to implementation details.

Abstraction and encapsulation are related features in object oriented programming. Abstraction allows making relevant information visible and encapsulation enables a programmer to implement the desired level of abstraction.

Encapsulation is implemented by using access specifiers. An access specifier defines the scope and visibility of a class member.

C# supports the following access specifiers:

Public

Private

Protected

Internal

Protected internal

answer Nov 25, 2014 by Jdk
Similar Questions
+1 vote

Hai Friends anybody say about Function Overloading in C#.net

+1 vote

Hai, friends anybody expalin Static Members in C#

...