For an operation of the form +x, unary operator overload resolution (?4.2.3)
is applied to select a specific
operator implementation. The operand is converted to the parameter type of
the selected operator, and the
type of the result is the return type of the operator. The predefined unary
plus operators are:
int operator +(int x);
uint operator +(uint x);
long operator +(long x);
ulong operator +(ulong x);
float operator +(float x);
double operator +(double x);
decimal operator +(decimal x);
For each of these operators, the result is simply the value of the operand.
is applied to select a specific
operator implementation. The operand is converted to the parameter type of
the selected operator, and the
type of the result is the return type of the operator. The predefined unary
plus operators are:
int operator +(int x);
uint operator +(uint x);
long operator +(long x);
ulong operator +(ulong x);
float operator +(float x);
double operator +(double x);
decimal operator +(decimal x);
For each of these operators, the result is simply the value of the operand.
本文详细介绍了C#中前置+运算符的工作原理及其实现方式。文章解释了如何通过重载运算符来实现特定类型的操作,并给出了内置类型的前置+运算符的具体表现。
144

被折叠的 条评论
为什么被折叠?



