Misc Operators


What are Misc Operators?

Besides arithmetic, logical, relational C# language provides some more valuable operators, known as miscellaneous operators. Misc operators are particular kinds of operators. Miscellaneous operators contain three operands: the first gets evaluated first if non zero, then the second gets evaluated and then the last one shows the result. Misc operators are helpful in reducing work by giving quick results. This operator directly works on the data and its address.

Operators

  • (?:) Operator - This operator is known as a conditional or ternary operator. In this operator condition, two operands get checked. Three operands get used. The first two are the operands whose condition gets checked, and the result shows in the third one.
  • sizeOf() : sizeOf() returns the size of the variable that we pass in it.
  • E.g. sizeOf(a) now if this a is an integer, then it will return 4. It returns as per the data type of the variable.

  • (&) : This operator returns the address of the given variable.
  • E.g. &a this will return the exact address of a.

  • (*) : This points to the memory location of the respective variable.
  • typeOF(): This operator returns the type of the class. E.g. typeof(StreamReader).