Operators:
Operators
suggest change| Parameter | Description |
|---|---|
| operatorSymbol | The operator being overloaded, e.g. +, -, /, * |
| OperandType | The type that will be returned by the overloaded operator. |
| operand1 | The first operand to be used in performing the operation. |
| operand2 | The second operand to be used in performing the operation, when doing binary operations. |
| statements | Optional code needed to perform the operation before returning the result. |
In C#, an operator is a program element that is applied to one or more operands in an expression or statement. Operators that take one operand, such as the increment operator (++) or new, are referred to as unary operators. Operators that take two operands, such as arithmetic operators (+,-,*,/), are referred to as binary operators. One operator, the conditional operator (?:), takes three operands and is the sole ternary operator in C#.
Syntax
public static OperandType operator operatorSymbol(OperandType operand1)public static OperandType operator operatorSymbol(OperandType operand1, OperandType2 operand2)
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents
2Operators
17Regex
18DateTime
19Arrays
21Enum
22Tuples
24GUID
27Looping
36Casting
46Methods
51Keywords
57Generics
79Overflow
88Events
92Structs
102Polymorphism
103Immutability
104Indexer
106Stream
107Timers
108Stopwatches
109Threading
111Async Await
123ICloneable
124IComparable
126Using SQLite
127Caching
135Pointers
145Cryptography
147C# Script
155Contributors