C # study notes (2) by Heiyeluren
Learn "Visual C # entry classic" learning notes
1. Static and instance class members static members (also known as shared members) are special members of the class, such as static methods, static properties, and more. Static members can share between instances of classes, so they can be seen as the whole
Object. Static attributes and static fields can access data independent of any object instance, and the static method can perform with the Type of Type, but not dedicated to the fame and fortune of the object instance.
Enough, when using a static member, there is no need for a powerful object.
For example, our existing console.writeline () and control.tostring () methods in our vs are static, do not need to instantiate the Console or Convert class at all (if the messenger
The power of the same strength will fail because the constructor of these classes is not public access. In many cases, static properties and methods have a good effect. For example, how many times can be created using an instance of a static attribute tracking class. General to a static attribute or method
In front, add static, such as: class class1 {public static int MeMBerProperty1; public static int memebermethod () {// code block ...}}
2. The interface interface is combined with implicit public methods and properties to encapsulate a collection of specific features. Once the interface is defined, you can implement it in the class. In this way, the class can support the interface finger.
All properties and methods are set. The interface cannot be alone, and the interface cannot be instantiated as an instantiation class. In addition, the interface cannot contain any code that implements its member, but only the member itself can be defined, and the execution process must be implemented in the class that implements the interface.
More detailed things will be discussed later. . .
Writetime: 2004-12-29 17:20