J
Javier Estrada
1. For types smaller than int, when I compile:
class MyClass
{
static void Main(string[] args)
{
[type] x = 10;
[type] y = -x;
}
}
where [type] is one of {sbyte, byte, short, ushort},
I receive error CS0029: Cannot implicitly convert
type 'int' to 'type'
2. When I compile with int, uint, long, no problem.
3. When I compile using ulong I receive error CS0023:
Operator '-' cannot be applied to operand of type 'ulong'
According to the documentation for the unary operator -
"Unary - operators are predefined for ALL numeric types.
The result of a unary - operation on a numeric type is
the negation of the operand."
Emphasis on ALL is mine.
This documentation is MISLEADING, since section 7.6.2 of
the C# Language Specification states that there are only
two unary operator overloads: for int and long, along
with the conversion rules.
Regards,
Javier
Please respond to the newsgroup so everybody can benefit
from the answer.
class MyClass
{
static void Main(string[] args)
{
[type] x = 10;
[type] y = -x;
}
}
where [type] is one of {sbyte, byte, short, ushort},
I receive error CS0029: Cannot implicitly convert
type 'int' to 'type'
2. When I compile with int, uint, long, no problem.
3. When I compile using ulong I receive error CS0023:
Operator '-' cannot be applied to operand of type 'ulong'
According to the documentation for the unary operator -
"Unary - operators are predefined for ALL numeric types.
The result of a unary - operation on a numeric type is
the negation of the operand."
Emphasis on ALL is mine.
This documentation is MISLEADING, since section 7.6.2 of
the C# Language Specification states that there are only
two unary operator overloads: for int and long, along
with the conversion rules.
Regards,
Javier
Please respond to the newsgroup so everybody can benefit
from the answer.