Home News DOC Class DL Others Cooker
Documents  >  Tutorial  >  Priority 1
Priority 1 operators

It describes the following operators with priority 1.


()x(y)Method call operator
newnew int()new operator
thisthisthis operator
[]x[y]indexer operator

These operators have the highest priority.


Table of contents:


Method call operator

new operator

this operator

indexer operator

Method call operator

The method call operator is an operation in order to call a method.


int i = 10;

string result = i.ToString() + " is 10."; // The result is "10 is 10."


The method call operator creates a signature from the method name and the argument. And, it calls an appropriate method.

As the above example, if there is a dot operator before the method name, the method call operator calls the method of the instance returned by the expression on the left side of the dot operator. Otherwise, the method call operator calls a method of the current instance.


A method call as an expression must return an instance. An exception will be thrown if you call a method with no return value as an expression.

new operator

The new operator is an operation in order to get an instance of the class specified by the fitter. The instance will be initialized with a fitter.


int i = new int(10); // 10.


You can get an instance of the desired class since the fitter name is the same as the class name.

this operator

The this operator is an operation in order to get the current instance.

indexer operator

The indexer operator is an operator for accessing items of the list class.

The left side of the operator must return an instance of the list class. The expression between [] must return an instance of the int class.


list il = new list("{100,101,102,103}"); // 100, 101, 102, 103

int i = il[0]; // i is 100.

i = il[1]; // i is 101.


If the indexer operator appears on the left side of the assignment statement, you can assign it to an item in the list.


il[0] = 1000; // il is 1000, 101, 102, 103.

If operands return the proxy class, the entity of the proxy is automatically used. The result is the same as calling the Entity getter of the proxy class.


list il = new list("{100,101,102,103}"); // 100, 101, 102, 103

proxy pro = new proxy(il);

proxy pro2 = new proxy(1);

i = pro[pro2]; // il[1].

pro[pro2] = 1002; // il[1] is 1002.

Next
Previous
Copyright © Rice All rights reserved.