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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:17:23+00:00 2026-06-15T19:17:23+00:00

I have 100,000 strings each with a fixed ordered index value like this: Index

  • 0

I have 100,000 strings each with a fixed ordered index value like this:

Index   String Value
  0     XXXXXXXXXXXXXXXXXXXXX
  1     XXXXXXXXXX
  2     (empty string)
  3     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  4     XXXXX
  5     XXXXXXXXX
  6     XXXXXXXXXXXXXXX
  7     (empty string)
  8     XX
  9     XXXXXXXXXX
 10     XXXXXXXXXXXXXXXXXXXXXXXXXX
 ...    ...
99999   XXXXXXXXXXXXXXXXXXX

My data structure must hold exactly 100,000 ordered entries and some (or many) of the string values may be empty, at least initially. Each index value will be unique (sequential integers) and, with the exception of empty strings, each string value will also be unique. For display purposes in my UI, I’d normally just populate my data structure, bind the listbox to it (with a DisplayMember and ValueMember specified). But in this case, I only want to display the strings that are not empty. So presumably, I’ll need to iterate through my data structure and add the applicable items to a listbox in a manner similar to this:

foreach (item in MyDataStructure)
{
    if (item.StringValue != string.Empty)
    {
        listBox1.Items.Add(item);
    }
}

It’s very important for me to be able to maintain the relationship between each string and its index value at all times. As you might expect, my users will need to add/edit/delete strings. In theory, all three operations boil down to the same thing: updating a string value at a particular index. To add a new string, I’ll need to first iterate through my data structure and make sure that there’s an empty string somewhere so I can replace it with the new string. If no empty strings exist, my user will need to “edit” an existing string or “delete” another string first because we’re dealing with a fixed number of total strings (100k). From a programmatic perspective, “deleting” a string is also just a matter of replacing it at the appropriate index in my data structure with an empty/null string.

As best as I can foresee, I’ll need a data structure that makes it easy to do the following:

  1. Add the index and string values for every non-empty string to a listbox and use the index as a ValueMember and the string as the DisplayMember.
  2. Quickly search the data structure for a particular index and retrieve its string value
  3. Quickly search the data structure for a string to see if it already exists

With those things in mind, can anyone recommend a particular data structure that lends itself to the task? I was initially thinking a dictionary with key/value pairs to hold each index/string. Then someone suggested just using an array since the total size is fixed and the array index itself could also serve as the index value for each string value.

  • 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-15T19:17:24+00:00Added an answer on June 15, 2026 at 7:17 pm

    Seeing as you have a fixed amount of items in your List and you require an index for each item, you need look no further than an array.

    string[] arr = new string[100000];
    

    You get access to LINQ for the array too so you can meet your criteria.

    //1
    arr.Where(x => !string.IsNullOrEmpty(x)).Select(str => new { value = Array.IndexOf(arr, str), display = str });
    //2
    string str = arr[index];
    //3
    arr.Any(x => x == "SomeString");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the list with like 100,000 site link strings Each link is unique,
I have a few long strings (~ 1.000.000 chars). Each string only contains symbols
I have a list of approx. 500,000 strings, each approx. 100 characters long. Given
I have a data set that looks like this: 000 100 200 300 010
I have to read 100.000 rows from database, I use this code : List<elementClass>
I have a database with almost 100,000 comments and I would like to detect
I have 100,000's of files that I would like to analyze. Specifically I would
With a list of around 100,000 key/value pairs (both string, mostly around 5-20 characters
There are about 100,000 different possible ways to encrypt a string. Using standards like
I have 100,000+ strings matched with a variable number of bytes 10-300. I will

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.