Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
A unary operator, in C#, is an operator that takes a single operand in an expression or a statement. The unary operators in C# are +, -,!, ~, ++, -- and the cast operator.
The signature of the declaration of a unary operator includes the operator token and the type of parameter; it does not require the return type and the name of the parameter.
All the C# unary operators have predefined implementation that will be used by default in an expression. These unary operators can be overloaded in user-defined types with custom implementation by defining static member functions using the "operator" keyword.
The list of unary operators with their details includes:
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.