C# protected

A protected variable or function can only be accessed within the class.

class phone
{
public double weight;
protected string make;
public phone(string m) { make = m; }
public string dial() { return "keyboard"; }
public string imake
{
get
{
return make;
}
set
{
make = value;
}
}
}
phone Lumia = new phone("Nokia");
Lumia.make = "Microsoft"; //Error, protected variable make can not be modified
Lumia.imake = "Microsoft";


endmemo.com © 2017  Terms of Use | Home