下面的代码代表了我正在尝试编写的内容。要求是税收概况应与正确的货币匹配。我在下面的代码中编写了 if 条件。但是,有 100 多个税务档案可通过数据库读取。我应该为所有 100 个条件编写 if 条件还是有更好的编码方式?
using System;
namespace MatchCondition
{
class MatchCondition
{
private const int TaxAmerica1 = 100;
private const int TaxAmerica2 = 200;
private const int TaxIndia1 = 300;
private const int TaxIndia2 = 400;
private const int Rupee =100;
private const int Dollar =200;
static void Main(string[] args)
{
try
{
int currencyId = int.Parse(args[0]);
int taxProfileId = int.Parse(args[1]);
if (currencyId == Rupee && (taxProfileId == TaxIndia1 || taxProfileId == TaxIndia2))
{
Console.WriteLine("All is well!");
}
else if(currencyId == Dollar && (taxProfileId == TaxAmerica1 || taxProfileId == TaxAmerica2))
{
Console.WriteLine("All is well!");
}
else if (taxProfileId == 0)
{
Console.WriteLine("All is well!");
}
else
{
Console.WriteLine("Mismatch Detected!");
}
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
}
}
}
}