X hits on this document

924 views

0 shares

0 downloads

0 comments

158 / 396

Chapter ‎18   Unsafe code

class Test { static void Main() { string s = null; Console.WriteLine("s = >" + s + "<");// displays s = >< int i = 1; Console.WriteLine("i = " + i);// displays i = 1 float f = 1.2300E+15F; Console.WriteLine("f = " + f);// displays f = 1.23E+15 decimal d = 2.900m; Console.WriteLine("d = " + d);// displays d = 2.900 } }

The result of the string concatenation operator is a string that consists of the characters of the left operand followed by the characters of the right operand. The string concatenation operator never returns a null value. A System.OutOfMemoryException may be thrown if there is not enough memory available to allocate the resulting string.

Delegate combination. Every delegate type implicitly provides the following predefined operator, where D is the delegate type:

D operator +(D x, D y);

The binary + operator performs delegate combination when both operands are of some delegate type D. (If the operands have different delegate types, a compile-time error occurs.) If the first operand is null, the result of the operation is the value of the second operand (even if that is also null). Otherwise, if the second operand is null, then the result of the operation is the value of the first operand. Otherwise, the result of the operation is a new delegate instance that, when invoked, invokes the first operand and then invokes the second operand. For examples of delegate combination, see §‎7.7.5 and §‎15.3. Since System.Delegate is not a delegate type, operator + is not defined for it.

7.7.5 Subtraction operator

For an operation of the form x y, binary operator overload resolution (§‎7.2.4) is applied to select a specific operator implementation. The operands are converted to the parameter types of the selected operator, and the type of the result is the return type of the operator.

The predefined subtraction operators are listed below. The operators all subtract y from x.

Integer subtraction:

int operator –(int x, int y); uint operator –(uint x, uint y); long operator –(long x, long y); ulong operator –(ulong x, ulong y);

In a checked context, if the difference is outside the range of the result type, a System.OverflowException is thrown. In an unchecked context, overflows are not reported and any significant high-order bits outside the range of the result type are discarded.

Floating-point subtraction:

float operator –(float x, float y); double operator –(double x, double y);

The difference is computed according to the rules of IEEE 754 arithmetic. The following table lists the results of all possible combinations of nonzero finite values, zeros, infinities, and NaNs. In the table, x and y are nonzero finite values, and z is the result of x y. If x and y are equal, z is positive zero. If x y is too

Copyright Microsoft Corporation 1999-2003. All Rights Reserved.145

Document info
Document views924
Page views924
Page last viewedWed Dec 07 14:44:58 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments