Encapsulation doubt in my code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NareshN
    New Member
    • Aug 2010
    • 45

    Encapsulation doubt in my code

    Hi All,


    I am using code like this in Business Logic.Can u explain 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

    Code:
    private string _Region;
    
    public string Region
    {
      get{return _Region;}
      set{_Region=value;}
    }
    Last edited by Frinavale; Nov 26 '10, 02:18 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    You should research the topic further.
    Encapsulation is the group of elements into a class and then using scope modifiers like public, private, protected etc. to specify what members of the class are accessible to calling code...and how they are accessible.

    -Frinny

    Comment

    Working...