How do I check if a number is positive or negative in C#?

前端 未结 17 1462
轻奢々
轻奢々 2020-12-04 05:55

How do I check if a number is positive or negative in C#?

17条回答
  •  眼角桃花
    2020-12-04 06:18

    You just have to compare if the value & its absolute value are equal:

    if (value == Math.abs(value))
        return "Positif"
    else return "Negatif"
    

提交回复
热议问题