vendredi 3 août 2018

How to check dynamic if conditions

I need to check dynamic if condition through my application. this is sample code of my application.

class Program
{
    static void Main(string[] args)
    {
        int newValue = 0;
        Console.WriteLine("Enter NO");
        int x = int.Parse(Console.ReadLine());
        if (10 < x && x < 20)
        {
            newValue = 1;
        }
        else if (20 < x && x < 30)
        {
            newValue = 2;
        }
        else
        {
            newValue = 3;
        }
    }
}

But I need to check those conditions (20 < x && x < 30) dynamically. How can I do this? I need to get those conditions through my database. which means I need to store those conditions in my database table. but there also have a problem. If database have those two conditions 20 < x && x < 30 and 10 < x && x < 40, when x = 25 both conditions will be through. So I also need to prevent store those invalid, confused conditions in a database. please give me a solution to do this. How I check dynamic if conditions through application & how to store conditions properly in my database (SQL Server)

Thank you.

Aucun commentaire:

Enregistrer un commentaire