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 118427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:29:35+00:00 2026-05-11T03:29:35+00:00

I am writing a piece of code that to work would require an extensive

  • 0

I am writing a piece of code that to work would require an extensive amount of if/then statements. In order to eliminate the need for writing line upon line of if/then statements can I use a dictionary or a list? If so can someone direct me to a good web resource or show an instance where they have done it before?

Edit

Clarification: I have six inputs, each are to be combo boxes with a group of selections. Below is a detail of the inputs and the selections.

(Amps) 1:1 – 1:12 (12 different selections)

(Cable Size) 2:1 – 2:13 (13 different selections) Certain items in this list will be excluded by the selection of the first input.

(Cable Type) 3:1 – 3:2 (2 different selections)

(Temp Rating) 4:1 – 4:3 (3 different selections)

(System Type) 5:1 – 5:2 (2 different selections)

(Conduit Type) 6:1 – 6:2 (2 different selections)

From the above input will come two outputs which will appear in two text boxes.

(Cable Qty) 7:1 – 7:16 (16 different outputs)

(Conduit Size) 8:1 – 8:8 (8 different outputs)

I hope this serves to help and not hinder.

  • 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. 2026-05-11T03:29:35+00:00Added an answer on May 11, 2026 at 3:29 am

    It looks like you’re trying to map each combination of the 6 inputs (12 * 13 * 2 * 3 * 2 * 2 possibilities) to one of the (16 * 8) outputs. If that’s the case, you’ll still have a lot of typing to do – but moving to a collection will allow you to easily externalize the mapping. I would guess that this would probably be best suited for a database table:

    Amps | CableSize | CableType | TempRating | SystemType | ConduitType | CableQty | ConduitSize 

    You’d put a primary key on the 6 input columns, and then just do a simple SELECT:

    SELECT CableQty, ConduitSize  FROM Table  WHERE Amps = @amps AND CableSize = @cableSize...etc 

    To do this in quick and dirty code, arrays would work:

    const int AMPS = 0; const int CABLE_SIZE = 1; const int TEMP_RATING = 2; // etc. var mappings = new Dictionary<int[], int[]>(12 * 13 * 2 * 3 * 2 * 2); mappings.Add(    new int[] { 1, 1, 1, 1, 1, 1 }, // inputs    new int[] { 1, 2 } //outputs ); // repeat...a lot  var outputs = mappings.First(inputs => {    inputs[AMPS] == myAmps    && inputs[CABLE_SIZE] == myCableSize    && inputs[TEMP_RATING] == myTempRating    && // etc }); 

    It doesn’t save you much typing – though you could use for loops and the like to populate the mappings if there’s some sort of logic to it – but it’s a hell of a lot more readable than 6 pages of if statements (I’d probably region off or partial class loading the mappings).

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

Sidebar

Related Questions

I'm writing a piece of code that requires the DOM of a website to
I was writing some Unit tests last week for a piece of code that
I'm currently writing a piece of code that does some searches which returns IDisposable
When I run a piece of code that I wrote I keep getting the
this is the piece of code that I am using in a loop to
I am writing a piece of code with high demands on performance where I
I'm writing a J2ME application. One of the pieces is something that polls the
Writing the code for the user authentication portion of a web site (including account
Writing a JSP page, what exactly does the <c:out> do? I've noticed that the
I'm working on a project that has a lot of legacy C code. We've

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.