以下のコードは、私が書き込もうとしているものを表しています。要件は、税プロファイルが正しい通貨と一致する必要があることです。以下のコードにif条件を記述しました。ただし、データベースを介して読み取られる100を超える税プロファイルがあります。それらの100個すべての条件を書く必要がありますか、それともコーディングするためのより良い方法がありますか?
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);
}
}
}
}