csharp notes - 1
1. The particular overload to call is determined statically (at compile time) rather than dynamically (at runtime).
2. Dynamic type checking is possible because each object on the heap internally stores a little type token. This token can be retrieved by calling the GetType method of object.
3. GetType is evaluated dynamically at runtime; typeof is evaluated statically at compile time.
4. A struct can have all the members a class can, except the following:
-
A parameterless constructor
-
A finalizer
-
Virtual members
A parameterless constructor that you can't override implicitly exists. This performs a bitwise-zeroing of its fields.
When you define a struct constructor, you must explicitly assign every field
5. internal: Accessible only within containing assembly or friend assemblies. The default accessibility for nonnested types
private: The default accessibility members of a class or struct
public: The implicit accessibility for members of an enum or interface
6. A type caps the accessibility of its declared members
class C { public void Foo( ) {} }
C's (default) internal accessibility caps Foo's accessibility, effectively making Foo internal
7. interface
1) A class can implement multiple interfaces
2) Interface members are all implicitly abstract
An interface can contain only methods, properties, events, and indexers, which noncoincidentally are precisely the members of a class that can be abstract.
Even though Countdown is an internal class, its members that implement IEnumerator can be called publicly by casting an instance of Countdown to IEnumerator.
As a general rule:
浙公网安备 33010602011771号