0
What is encapsulation??? Example code c#???
3 ответов
+ 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
+ 9
you are welcome :)
0
You're the first, who have explained me about encapsulation. Thanks man ;)