answersLogoWhite

0

What is encapsulation in c sharp?

Updated: 10/23/2022
User Avatar

Wiki User

13y ago

Best Answer

I think the question should be modified as "What is the encapsulation in Object-Oriented programming?" instead of in C#.

C# itself is not encapsulated. It supports OO programming, and encapsulation is one of the main characteristics of OO programming".

The encapsulation in plain English is to hide a piece of information (data) or behavior (the code) within the object itself. Outside of the object should not and cannot know about it.

For instance, let's say you want to add 1 to a property of an object:

Person me = new Person();

me.Wallet.Content += 1;

The above shows the traditional way of adding 1 to the content of my wallet. But if you examine the code carefully, it was like:

"give me all the contents in your wallet, I'll add 1 to those, then put the new contents back in". There is no encapsulation in that code segment.

Person me = new Person();

me.AddToWalletContent(1);

The above code segment shows a way of encapsulation. Noted that there is no property of Wallet, no property of Content of a Wallet directly being seen here.

That's the encapsulation in a nut shell.

How the object me (an instance of Person) implements AddToWalletContent(int aNumber) is not the concern of the consumer, and the consumer has no knowledge (does not know, and should not know) about the person has a wallet or not, and if he does, what the contents were before adding 1 to them.

I hope the above examples shed some lights about encapsulation in OO.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is encapsulation in c sharp?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Can abstraction encapsulation be achieved in C program if yes explain?

abstraction and encapsulation is one of the concepts of OOPs and C is not an OOP [Object Oriented Programming language] obviously abst & encap will not be supported by 'C' Abstraction & encapsulation is a concept of OOP [Object Oriented Programming] But, 'C' is not an OOP whereas it is a POP [Procedure oriented programming], so obviously 'C' does not support abstraction and encapsulation Answer Encapsulation is not inherently supported but it can be emulated in C. The use of static and extern keywords for functions are almost equivalent to your private and public keywords in java (encapsulation). Read up more on those keywords.. Structures become an object's attributes while functions accepting pointers the the said struct become its methods.


What is encapsulation in c?

Assume you were asking as in C#, not C. Because C is not an OO language, thus if there is encapsulation, it would be different.The encapsulation in any OO language is to hide the information of data and the implementation detail of a method.For example, you have a bank account as a private data member. Any one can ask you about the Balance of your bank account, e.g. GetDeposits(), an operation that is public. Wait, you now are richer, and you open 2 more bank accounts, the public still has the only accessing method GetDeposits(), to get your total deposits.The encapsulation in this abstraction are:1. The detail, the implementation of GetDeposits(), is not revealed to public.2. The data member, 1 account or 3 accounts, no one got impact, and no one knows. (in fact, no one knows how many bank accounts you have!)


Which is the most common encapsulation in use on BRI Interface?

Which is the most common encapsulation in use on BRI Interface ? A. SDLC B. ATN C. HDLC D. PPP


What is the term that describes the hiding of implementation details of objects from each other in a C plus plus class?

Encapsulation.


Does c sharp work on c or c plus plus compilers or you need a c sharp compiler?

They are different languages, each of them requires its own compiler.

Related questions

What is data abstraction in c sharp?

Abstraction means that all information exist but only the relevent information is provided to the user. Encapsulation assists abstraction by providing a mean of suppressing the non-essential details.


Can abstraction encapsulation be achieved in C program if yes explain?

abstraction and encapsulation is one of the concepts of OOPs and C is not an OOP [Object Oriented Programming language] obviously abst & encap will not be supported by 'C' Abstraction & encapsulation is a concept of OOP [Object Oriented Programming] But, 'C' is not an OOP whereas it is a POP [Procedure oriented programming], so obviously 'C' does not support abstraction and encapsulation Answer Encapsulation is not inherently supported but it can be emulated in C. The use of static and extern keywords for functions are almost equivalent to your private and public keywords in java (encapsulation). Read up more on those keywords.. Structures become an object's attributes while functions accepting pointers the the said struct become its methods.


What is encapsulation in c?

Assume you were asking as in C#, not C. Because C is not an OO language, thus if there is encapsulation, it would be different.The encapsulation in any OO language is to hide the information of data and the implementation detail of a method.For example, you have a bank account as a private data member. Any one can ask you about the Balance of your bank account, e.g. GetDeposits(), an operation that is public. Wait, you now are richer, and you open 2 more bank accounts, the public still has the only accessing method GetDeposits(), to get your total deposits.The encapsulation in this abstraction are:1. The detail, the implementation of GetDeposits(), is not revealed to public.2. The data member, 1 account or 3 accounts, no one got impact, and no one knows. (in fact, no one knows how many bank accounts you have!)


What are the notes to?

A sharp G G E sharp G E sharp A sharp A sharp C C A sharp C E sharp G A G E sharp A sharp A sharp A sharp G E sharp C this is not on the Flute btw idk what instrument its on


What are the notes to fireflies?

A sharp G G E sharp G E sharp A sharp A sharp C C A sharp C E sharp G A G E sharp A sharp A sharp A sharp G E sharp C this is not on the flute btw idk what instrument its on


How do you play Simpson theme on keyboard?

here it is C,E,F SHARP,A,G,E,C,A,F SHARP,F SHARP,F SHARP,G,A SHARP,C,C,C,C


Which is the most common encapsulation in use on BRI Interface?

Which is the most common encapsulation in use on BRI Interface ? A. SDLC B. ATN C. HDLC D. PPP


What key signature has G sharp B sharp and C sharp?

C# Major


What are the notes for the c sharp harmonic scale?

C sharp, D sharp, E natural, F sharp, G sharp, A natural, B sharp & C sharp We call the note C "B sharp" to avoid using the same letter name twice. If we used the note name "C" we would have 2 C-notes and no B-notes in the scale!


What is the tonic note for C sharp minor?

The tonic is C sharp.


What is the name of the process of building a frame around network layer information?

Encapsulation. Actually, this is one type of encapsulation; encapsulation occurs at several layers.Encapsulation. Actually, this is one type of encapsulation; encapsulation occurs at several layers.Encapsulation. Actually, this is one type of encapsulation; encapsulation occurs at several layers.Encapsulation. Actually, this is one type of encapsulation; encapsulation occurs at several layers.


What major scale has 7 sharps?

That would be C-sharp major. Every note is sharp.