Export (0) Print
Expand All
1 out of 3 rated this helpful - Rate this topic

* Operator

The multiplication operator (*) computes the product of its operands. All numeric types have predefined multiplication operators.

expr1 * expr2

Where:

expr1
An expression.
expr2
An expression.

Remarks

The * operator is also used to declare pointer types and to dereference pointers (see A.2 Pointer types).

User-defined types can overload the * operator (see operator).

Example

// cs_operator_mult.cs
using System;
class Test 
{
   public static void Main() 
   {
      Console.WriteLine(5 * 2);
      Console.WriteLine(-.5 * .2);
      Console.WriteLine(-.5m * .2m); // decimal type
   }
}

Output

10
-0.1
-0.10

See Also

C# Operators | 7.7.1 Multiplication operator

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.