* Operator (C# Reference)

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

* also serves as the dereference operator, which allows reading and writing to a pointer.

Remarks

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.

Example

class Multiply
{
    static void Main() 
    {
        Console.WriteLine(5 * 2);
        Console.WriteLine(-.5 * .2);
        Console.WriteLine(-.5m * .2m); // decimal type
    }
}
    /*
Output
    10
    -0.1
    -0.10
*/

Example

public class Pointer
{
    unsafe static void Main()
    {
        int i = 5;
        int* j = &i;
        System.Console.WriteLine(*j);
    }
}
/*
Output:
5
*/

See Also

C# Reference
C# Programming Guide
Unsafe Code and Pointers
C# Operators