📜  C# 如果有小数部分 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:43.299000             🧑  作者: Mango

代码示例1
For floating point numbers, n % 1 == 0 is typically the way to check if there is anything past the decimal point.

public static void Main (string[] args)
{
    decimal d = 3.1M;
    Console.WriteLine((d % 1) == 0);
    d = 3.0M;
    Console.WriteLine((d % 1) == 0);
}

//Output:
False
True