Read "C # primer" notes 2

zhaozj2021-02-16  75

Chapter II Class Design

1, the indexers indexer can establish an index as a class or structure instance in the same way as the array, and the indexer looks a bit like Property, which provides a GET / SET Accessor as well as Property. Different, here should be

Keyword THIS indicates Indexers and requires at least one index parameter, which can be arbitrary.

2. The delegate delegate is substantially similar to the function pointer in C . DELEGATE Types: ◎ Delegate Object can simultaneously represent multiple member functions; ◎ Multiple functions represented by DELEGATE OBJECT (pointing) are not necessarily the member functions belonging to the same class. All functions represented by Delegate Object must have

The same prototype (prototype) and tag; ◎ declare a Delegate type, equal to a new sub-entity (subtype) entity that creates "DELEGATE or MulticastDelegate abstract base class" internally created ".NET Library Framework", these two

Abstract base classes provide a set of public functions that supports "Query DELEGATE OBJECT and their fingers)

Note: MulticastDelegate represents multi-channel broadcast delegation; that is, it can have a delegation of multiple elements in the list of calls. It is a special class, compiler and other tools to derive from this class, but

You cannot explicitly derive from this class.

3, REF and OUT ◎ REF, OUT method parameter keyword makes the method reference to the same variable to the method. Any changes made to the parameters in the method are reflected in the variable when the control is transferred back to the mode. To make

With REF, OUT parameters, parameters must be explicitly passed to methods as REF, OUT parameters. The value of the REF parameter is passed to the REF parameter, but the value of the OUT parameter does not pass to the OUT parameter ◎ Parameters pass to the REF parameter must be initialized, but the OUT parameter does not need, but the OUT parameter must be assigned in the function. ◎ Attribute is not Variables cannot be passed as REF, OUT parameters.

4. Params ◎ Params Keyword You can specify a method parameter of parameters in parameters variable. ◎ No other parameters are allowed after the params keyword in the method declaration, and only one params keyword is allowed in the method declaration.

5, operator overload ◎ must be declared as public static ◎ must have a parameter to be the type of operator ◎ Change the number of operators originally defined ◎ If the True operator must also define the FALSE operator, both must Returns the BOOL value ◎ , - an operator must return an instance of the type of its belongings ◎ can be overloaded one yuan operator: , - ,! , ~, , -, true, false ◎ can be overloaded binary operators: , -, *, /,%,! , ^ (No or), <,>, <<, >>, ==,! =, <=,> = ◎ Not allowed to be overloaded operators: &&, ||, =,? :, =, - =, / =,% =, | =, ^ =, << =, >> =, in fact, some "duplex operators" automatically generate after the binary operator is overloaded, and Can't explicitly define ◎ Must be used to overload operators: (==,! =), (<>), (<=,> =) ◎ , - operator is not distinguished when Or behind

Related resources: with sound access new year fireworks animation effects - html-code

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

New Post(0)