Access modifiers
There are 4 of
Commonly used to have
Public: As long as the namespace is referenced, you can access it freely.
Private: Only within the current class can be accessed
Not used.
Internal: Internal, accessible within the current assembly, the Assembly is the namespace, this modifier is the default
Protected: Protected, the current class and its subclasses are accessible
Namespaces:
Also called an assembly, each folder in the project is a separate namespace
If you want to use a class file under one of the namespaces, you must first reference this namespace
Encapsulation: packing and sealing up;
Example:
private string _code;
public string Code
{
Get
{
return _code;
}
set {_code = value;}
}
Restrictions can be added to the set;
A member variable can have a number of properties
The property return type can be any type, not must be the same as the member variable type
Properties can be read-only or write-only, or they can have both
Inherited:
Subclasses can inherit all public methods and properties of the parent class
The parent class cannot invoke the methods and properties of a subclass, even if the
The subclass can be converted to a parent class, and the converted parent can be converted back to the appropriate subclass.
The subclass is converted to a parent class that cannot be converted to another subclass
Parent class
Subclass-Subclass of a class, derived class, superclass
Access modifiers, encapsulation, inheritance