* Operator
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

* 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

Show:
© 2016 Microsoft