Priority 1 operators

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

These operators have the highest priority and left-associativity.


Table of contents:


Method call operator

new operator

this operator

indexer operator

Method call operator

The method call operator is an operation 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 arguments, and calls appropriate method.

As the above example, if there is the dot operator before the method name, the method call operator calls the method of the instance returned by the dot operator. Otherwise, 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 gets 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 gets the current instance.

indexer operator

The indexer operator accesses an item of the list class.

The left operand of the operator must return the list class. The expression between [] must return 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 of the assignment statement, you can assign to the item of 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.

Copyright © Rice All rights reserved.