Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8806241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:04:57+00:00 2026-06-14T02:04:57+00:00

The code below represents what I am trying to write. The requirement is that

  • 0

The code below represents what I am trying to write. The requirement is that the tax profile should match the correct currency. I have written the if conditions in my code below. However there are more than 100 tax profiles that are read via a database. Should I write if conditions for all 100 of them or is there a better way to code?

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);
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:04:58+00:00Added an answer on June 14, 2026 at 2:04 am

    You can put all your valid combinations in a hashtable, i.e. IDictionary and go from there.

    For example:

    var validCombinations = new Dictionary<int, List<int>>();
    validCombinations.Add(Rupee, new List<int> { TaxIndia1, TaxIndia2 });
    validCombinations.Add(Dollar, new List<int> { TaxAmerica1, TaxAmerica2 });
    
    int currencyId = int.Parse(args[0]);
    int taxProfileId = int.Parse(args[1]);
    
    List<int> validTaxes;
    
    if (taxProfileId == 0 ||
        (validCombinations.TryGetValue(currencyId, out validTaxes) &&
         validTaxes.Contains(taxProfileId)))
    {
        Console.WriteLine("All is well!");
    }
    else
    {
        Console.WriteLine("Mismatch Detected!");
    }
    

    You could also populate the dictionary with combinations read from a database table, so you don’t have to hardcode them. YMMV.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: C++'s “placement new” in the below code what does Line 3 represents,
Code below is working well as long as I have class ClassSameAssembly in same
The code below simply didn't work. document.getElementById('files').addEventListener('change', handleFileSelect, false); reported by firebug that this
Using the C# code below, how would you write it in Visual Basic? What
I am trying to re-write an existing system with objects. I have created a
I'm trying to parse a String that represents a date using GMT, but it
I'm just trying to understand the below code : Here a new type alias
I'm trying to an indexof method for a class that represents a list of
I am trying to port some code from Delphi to C# and I have
Given the Java code below, what's the closest you could represent these two static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.