locked
How to do divide odd number and even number values in ASPNET C# framework 4.7.2 RRS feed

  • Question

  • User314352500 posted

    Hi all,

    I need your help.

    This is part of my table on MySQL database

    +--------+-----------+--------------+---------------+-------------+
    | sLevel | sName     | sCountryCode | sDidtrict     | sPopulation |
    +--------+-----------+--------------+---------------+-------------+
    |      1 | Kabul     | AFG          | Kabol         | 1780000     |
    |      3 | Amsterdam | NLD          | Noord-Holland | 731200      |
    |      4 | Rotterdam | NLD          | Zuid-Holland  | 593321      |
    |      5 | Haag      | NLD          | Zuid-Holland  | 440900      |
    |      2 | Qandahar  | AFG          | Qandahar      | 237500      |
    |      8 | Utrecht   | NLD          | Utrecht       | 234323      |
    |      6 | Eindhoven | NLD          | Noord-Brabant | 201843      |
    |      7 | Tilburg   | NLD          | Noord-Brabant | 193238      |
    +--------+-----------+--------------+---------------+-------------+

    The column sLevel contains integer value.

    If the value of column sLevel it's an even number, I need to do reading on another table

    Instead the value of column sLevel it's an odd number, I need to write on another table

    Normally I would write this

    if(sLevel == 1 || sLevel == 3 || sLevel == 5 || sLevel == 7)
    {
       //Write
    }
    else
    {
       //Read
    }

    But every time a new row is inserted in the table I should to insert on the condition the sLevel new value

    Do you know if you can set a function in ASPNET C# that recognizes odd numbers?

    Thanks in advance for any help

    Saturday, May 16, 2020 6:56 PM

All replies