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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:13:38+00:00 2026-05-13T01:13:38+00:00

What is the most efficient way to do look-up table in C# I have

  • 0

What is the most efficient way to do look-up table in C#

I have a look-up table. Sort of like

0 "Thing 1"
1 "Thing 2"
2 "Reserved"
3 "Reserved"
4 "Reserved"
5 "Not a Thing"

So if someone wants “Thing 1” or “Thing 2” they pass in 0 or 1. But they may pass in something else also.
I have 256 of these type of things and maybe 200 of them are reserved.

So what is the most efficient want to set this up?

  • A string Array or dictionary variable that gets all of the values. And then take the integer and return the value at that place.

One problem I have with this solution is all of the “Reserved” values. I don’t want to create those redundant “reserved” values. Or else I can have an if statement against all of the various places that are “reserved” but they might now be just 2-3, might be 2-3, 40-55 and all different places in the byte. This if statement would get unruly quick

  • My other option that I was thinking was a switch statement. And I would have all of the 50ish known values and would fall through through and default for the reserved values.

I am wondering if this is a lot more processing than creating a string array or dictionary and just returning the appropriate value.

  • Something else? Is there another way to consider?
  • 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-05-13T01:13:38+00:00Added an answer on May 13, 2026 at 1:13 am

    “Retrieving a value by using its key is very fast, close to O(1), because the Dictionary(TKey, TValue) class is implemented as a hash table.”

    var things = new Dictionary<int, string>();
    things[0]="Thing 1";
    things[1]="Thing 2";
    things[4711]="Carmen Sandiego";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get data in the most efficient way possible for some reports, using
I need the most efficient way to filter out Nodes from a XmlNodeList. The
What is the most efficient way to check if the current QTP test execution
In my text the user can input modules which look like this; [[form:contact]] ,
I first have to say that I really am a rookie in caching, so
Considering this table: create table x (id int, total int, diff int) And this
We have a website that lists links to blogs in realtime. The problem is
I have a python script that creates a list of lists of server uptime
Just for fun I would like to count the conditional probabilities that a word
Say [a,b] represents the interval on the real line from a to b, a

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.