locked
Error - Type of conditional expression cannot be determined because there is no implicit conversion between decimal & Bollean. RRS feed

  • Question

  • User-1499457942 posted

    Hi

     On below line i am getting above error

    if(dt.Rows[i]["Sh1"] != DBNull.Value ? Convert.ToDecimal(dt.Rows[i]["Sh1"]) : 0 > 0);

    Thanks

    Monday, October 15, 2018 7:17 AM

All replies

  • User1724605321 posted

    Hi JagjitSingh ,

     Convert.ToDecimal(dt.Rows[i]["Sh1"]) is Decimal type  , 0 > 0 is Bool type(False ) . Base on your requirement , you can modify your code . For example :

                    if (dt.Rows[i]["Sh1"] != DBNull.Value ? true : false) {
                    }

    Best Regards,

    Nan yU

    Monday, October 15, 2018 7:34 AM
  • User-398246787 posted

    you statement is wrong

    you are using a short form of If in If Condition

    more over 0>0 is invalid

    what are you trying to do?

    Wednesday, October 17, 2018 3:07 AM