When it comes to encapsulation, it is actually a problem of basic classes. It provides the implementation means of interaction between systems, modules, classes and classes for program design. In. net, everything seems to have been packaged in. net FrameWork is a complex network that provides tens of thousands of types, methods, and interfaces to end developers, and everything in the Framework is encapsulated.
As a junior GIS programmer, there is no reference to encapsulating macro concepts. Programming often faces "Fields, attributes, and methods", which is also one of the basic concepts of object-oriented.
It is usually defined as private, indicating the status information of the class. CLR supports read-only and read-write fields. The read-only field can only be assigned a value in the constructor. Other methods cannot change the read-only field. Common field definitions:
Private string name;
Private int age;
It is usually defined as public, indicating the external member of the class. Attributes are readable and writable. You can use get and set accessors to implement read/write control. If the attribute is read-only, only get accessors can be implemented. If the attribute is writable, set accessors can be implemented. There is also a property containing parameters, which is called the indexer in c.
Public {= value =?
In fact, this is directly intelligent in VS2010. It is okay to select a field, select reconstruction, and encapsulate the field.
Methods encapsulate the behaviors of classes and provide external representations of classes. The method is used to provide external interfaces with public methods for encapsulated internal details. The method for external interaction is usually implemented as public. However, the internal operations in the class are basically implemented in private mode, ensuring the hiding and protection of internal data. In VS2010, you can also select a code segment, select reconstruction, and extract methods.