Compiler Error CS0664

Literal of type double cannot be implicitly converted to type 'type'; use an 'suffix' suffix to create a literal of this type

An assignment could not be completed; use a suffix to correct the instruction. The documentation for each type identifies the corresponding suffix for the type. For more information on conversions, see Casting and Type Conversions (C# Programming Guide).

The following example generates CS0664:

// CS0664.cs
class Example
{
    static void Main()
    {
// CS0664, because 1.0 is interpreted as a double:
        decimal d1 = 1.0;   

        // Try the following line instead.
        // The M informs the compiler that 1.0 is a decimal.
        decimal d2 = 1.0M;  
        Console.WriteLine(d2);
    }
}

See Also

Concepts

Type Conversion Tables

Change History

Date

History

Reason

December 2008

Clarified the example.

Customer feedback.