如果我想在代码中使用decimal-literal,我已经看到存在m后缀(其中m代表金钱).这是否适用于任何小数或存在更一般的分配(d代表double,即为了shure而不是正确的东西,虽然支持直接转换).
object decimalValue=2m;
Run Code Online (Sandbox Code Playgroud)
请注意,我以对象分配为例,因为在...的情况下
decimal decimalValue=2;
Run Code Online (Sandbox Code Playgroud)
...它隐含的明确,2应该通过编译器解释为十进制.
编辑: m似乎没问题,msdn使用它作为十进制类型的示例.
我的代码中存在问题,即使我将其指定为双精度数据类型,平均值也是整数。可能是什么问题呢?
using System;
using static System.Console;
using System.Linq;
class TemperaturesComparison
{
static void Main()
{
int[] temp = new int[5];
int i = 0;
while (i < 5)
{
int eachTemp = int.Parse(ReadLine());
if (eachTemp < -30 || eachTemp > 130) continue; //skips
temp[i] = eachTemp;
i++;
}
if (temp[0] < temp[1] && temp[1] < temp[2] && temp[2] < temp[3] && temp[3] < temp[4]) WriteLine("Getting warmer");
else if (temp[0] > temp[1] && temp[1] > temp[2] && temp[2] > temp[3] && …Run Code Online (Sandbox Code Playgroud)