VB programmer C # 5

zhaozj2021-02-08  234

The basic class is a class that inherits. Detective classes are classes that inherit a basic class.

Constructor (constructor)

The constructor is a method that calls it when constructed an object of a class, usually used when initializing a class. A constructor method is the same as the name of the class, and does not return type and does not return any values.

REF and OUT

Marking a parameter as a REF type means that any modifications to its value will remain, which is similar to the 'by reference' of VB. For example, the routine code is executed, the value of the P is changed:

Void Refmethod (Ref Int N)

{

N = 3;

}

INT P = 3;

Refmethod (Ref P);

When the method needs to assign a value to the parameter, use OUT, such as in the following generation, the value of the P is set:

Void Outmethod (Out Int N)

{

n = 3;

}

Int P;

OUTMETHOD (OUT P)

OVERLOADING

In C #, overloading allows us to declare more than one way with the same name, while requiring them to be different on the number of variables and / or types, so that the computer can distinguish which method.

REFLECTION

Reflection is the ability to get object information at runtime, which is the same as the number of TYPEOF operators in VB. But there is also the same GetType () in C #. C # uses type objects for Reflection, or it can be used to obtain all metadata in the object.

转载请注明原文地址:https://www.9cbs.com/read-3268.html

New Post(0)