What is encapsulation??? Example code c#??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is encapsulation??? Example code c#???

28th Nov 2016, 1:56 PM
Tamil Karthi
Tamil Karthi - avatar
3 Answers
+ 9
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 Example :-  class Base { public int id; private string name; } Static Void Main(string [] args) { Base b=New Base(); b.id=1; b.name="vishal" //error } in this Example there is class Base with two objects id and name id is public so it is accessible with in class and out side of class but name is encapsulated to private so it is only accessible with on class not for out side of class
28th Nov 2016, 3:04 PM
Hassan Amr
Hassan Amr - avatar
+ 9
you are welcome :)
28th Nov 2016, 7:02 PM
Hassan Amr
Hassan Amr - avatar
0
You're the first, who have explained me about encapsulation. Thanks man ;)
28th Nov 2016, 6:57 PM
Михаил Костенко