Win Surprise Gifts!!!
Top 5 Contributors of the Month
Post New Question
Subscribe to Forum
Encapsulation Doubt in my code
November 30, 2010
Can u tell me whether i am using Encapsulation concept in below code.Why i should use private for variable and public for property.
Can u give any other example for Encapsulation with code .
private string _UserName;
public string UserName
Posted Date: December 06, 2010 Points: 5
With help of private data we are maintaining security purpose, Encapsulation means security the data,the above code private variable is called encapsulation concept.
Posted Date: September 16, 2011 Points: 20
When you create an object out of that class, then your object encapsultes Username.
private variables cannot be used outside the class, whereas public variables can be used by the objects outside the class.
another example :
public int seats;
public void inceaseSpeed()
public void decreseSpeed()
static void Main(string args)
Car mycar = new Car();
mycar.seats = 4;
Encapsulation: seats, inceaseSpeed() and decreseSpeed()are encapsulated in car
Abstraction:inceaseSpeed() and decreseSpeed() ,driver need not know how they work
To post reply
Related Questions Related Questions
Code Logic doubt for 2 D Array
Encapsultion doubt in my code
difference between the code in encapsulation concept.
What is Code Access Security in .NET
Having a doubt in SQL query
Doubt on ''createuserwizard'' control?
protection in C#.NET source code
Doubt in Date/time
Doubt on features of .NET Framework
Latest Forum Questions From The Same Category
how to learn and Where can i Learn about ASP .Net
Slash(/) in Combobox
attaching the report in the web page
How do i get payment status in redirect page using bitpay?
Login with Facebook and Save details in database
Login with facebook account in my website
How to make a nested datalist control?
What class does Icon derive from?
What are the validation controls?
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more
Quick Links For Forum Categories:
Hall of Fame
Terms of Service
Tell A Friend