编译器错误 CS0664
无法将 Double 类型隐式转换为“type”类型;请使用“suffix”后缀创建此类型
赋值无法完成,请使用后缀更正指令。 每个类型的文档确定该类型的相应后缀。 有关转换的详细信息,请参阅强制转换和类型转换。
下面的示例生成 CS0664:
C#
// CS0664.cs
class Example
{
static void Main()
{
decimal d1 = 1.0; // CS0664, because 1.0 is interpreted
// as a double.
// Try the following line instead.
decimal d2 = 1.0M; // The M tells the compiler that 1.0 is a
// decimal.
Console.WriteLine(d2);
}
}