Why does Math.Floor(Double) return a value of type Double?

后端 未结 6 590
一生所求
一生所求 2020-12-10 10:22

I need to get the left hand side integer value from a decimal or double. For Ex: I need to get the value 4 from 4.6. I tried using Math.Floor function but it\'s returning a

6条回答
  •  無奈伤痛
    2020-12-10 10:37

    Convert.ToInt32(Math.Floor(Convert.ToDouble(value)))
    

    This will give you the exact value what you want like if you take 4.6 it returns 4 as output.

提交回复
热议问题