Breaking News
Loading...
Friday 29 March 2013

What is Encapsulation in C#.Net

  •  
  • Encapsulation is process of hiding complex processing outside the word means you can create cover over data which protect the data from accessing outside word.
  • Encapsulation can be achieved by using keyword like Public, private, Protected…..

Example:

public class Department
{
         private string departname;

         // Accessor.
         public string GetDepartname()
         {
                  return departname;
         }
         // Mutator.
         public void SetDepartname( string a)
         {
                   departname=a;
         }
}
public static int Main(string[] args)
{
         Department d = new Department();
         d.SetDepartname("ELECTRONICS");
         Console.WriteLine("The Department is :"+d.GetDepartname());
          return 0;
}

See Also :
  Follow Me On Facebook
--
/\/ir@\/  <(.'.)>

0 comments:

Post a Comment

Thanks for comment

 
Toggle Footer