* 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 (C# Reference)

The multiplication operator (*), which computes the product of its operands. Also, the dereference operator, which allows reading and writing to a pointer.

All numeric types have predefined multiplication operators.

The * operator is also used to declare pointer types and to dereference pointers. This operator can only be used in unsafe contexts, denoted by the use of the unsafe keyword, and requiring the /unsafe compiler option. The dereference operator is also known as the indirection operator.

User-defined types can overload the binary * operator (see operator). When a binary operator is overloaded, the corresponding assignment operator, if any, is also implicitly overloaded.

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


// cs_operator_ptr.cs
// compile with: /unsafe
public class MainClass
    unsafe static void Main()
        int i = 5;
        int* j = &i;

© 2015 Microsoft