Unary Operator

Definition & Meaning

Last updated 23 month ago

What is a Unary Operator?

A unary Operator, in C#, is an operator that takes a single Operand in an Expression or a assertion. The unary Operators in C# are , -,!, ~, , — and the forged operator.

The signature of the announcement of a unary operator consists of the operator Token and the sort of Parameter; it does now not require the return type and the name of the parameter.

All the C# unary operators have predefined Implementation a good way to be used by default in an expression. These unary operators may be overloaded in user-described kinds with custom implementation through defining Static member Functions using the "operator" key-word.

What Does Unary Operator Mean?

The listing of unary operators with their info includes:

  • Unary Plus Operator ( ): The end result of an operation on a numeric kind is the fee of the operand itself. ThIS Operator has been predefined for all numeric kinds.
  • Unary Minus Operator (-): This operator can be used to negate numbers of the Integer, Floating-point and Decimal type.
  • Logical Complement (negation) Operator (!): This operator may be used most effective with operands of Boole kind.
  • Bitwise Complement (negation) Operator (~): This operator may be used with integer, uNit, long and ulong operand sorts. The end result of the operation is a bitwise supplement (inverse of the Binary representation) of the operand.
  • Prefix Increment ( ) and Decrement (–) Operator: The operand can be a Variable, property get right of entry to, or an Indexer get right of entry to. With an Increment Operator, the result of the operation for operands of integer kind would be the fee incremented by 1. With a Decrement Operator, the result will be the value decremented by means of 1 from the operand. The increment/decrement operator can also be used with postfix notation
  • Cast Operator: Used to Build cast expressions for conversion to a given kind. This operator is represented by the image, "T," in which T is the sort to which the operand or the result of the expression need to be transFormed

Share Unary Operator article on social networks

Your Score to Unary Operator article

Score: 5 out of 5 (1 voters)

Be the first to comment on the Unary Operator

10261- V4

tech-term.com© 2023 All rights reserved