Encapsulation
1. We can combine both behavior and functionality
both together with the wrapper of class. This means that a class which has data
member as well as method is called encapsulation.
3. Class is the best example of encapsulation.
By using the get and set methods (Accessors
and Mutators)
public class Account
{
private string accoutName;
// get methods
public string GetAccount()
{
return accoutName;
}
// Set method
public void SetAccount(string name)
{
accoutName = name;
}
}
static void Main()
{
string name ="SAVING_ACCOUNT";
Account account = new Account();
account.SetAccount(name);
name = string.Empty;
name = account.GetAccount();
}