.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Encapsultion doubt in my code

Posted By: Naresh     Posted Date: November 26, 2010    Points:2   Category :ASP.Net
Hi All,

I am using code like this in Business Logic.Can u explian the below whether i am using Encapsulation concept in the below code.Also tell me why i should use private for declaring variable _Region and public for the property Region

private string _Region;

public string Region
get{return _Region;}

Author: Dhilip.R             
Posted Date: November 27, 2010     Points: 5   


_Region is a private variable because the scope of the variable is with in the class only.But,The property is a public property of the entire project.

If you want to use _Region as another class private variable you can use..

Author: SureshM             
Posted Date: December 01, 2010     Points: 5   


_Region is the "member variable" of the class.

Region is the "Property variable" of the class.

When you access the Region(Property) in another class.
The Property variable is changing through the Member variable (_Region)..

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend