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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:21:40+00:00 2026-05-25T00:21:40+00:00

I have a list and I am getting each item in the list in

  • 0

I have a list and I am getting each item in the list in a foreach loop.

    private void saveButton_Click(object sender, EventArgs e)
    {
            if (saveFile1.ShowDialog() == DialogResult.OK)
            {
                StreamWriter sw = new StreamWriter(saveFile1.FileName);
                int i = 1;

                Dictionary<string, int> dictionary = new Dictionary<string, int>();

                foreach (var line in theFinalList)
                {
                    //compareList.Add(line.PartNumber[]);
                    if (!line.Name.Contains("FID") || !line.PartNumber.Contains("FIDUCIAL") ||
                        !line.PartNumber.Contains("EXCLUDES") || !line.PartNumber.Contains("excludes"))
                    {
                        //This doesn't work obviously.. :/
                        sw.WriteLine("( {0} 0 1 1 0 0 0 0 \"{1}\" \"{2}\" \"\" {3} 0 0 0 0 0 )",
                            i, line.PartDescription, line.PartNumber, partNumberOccurrences);
                    }

                    i++;
                }
            }

And I am having trouble using a dictionary to store each part of the line in a dictionary and to increment the the itemCounter whenever it is found as duplicate. I am trying to do something like this, but I cannot figure out the logic for it.

And I would like to only output the partNumber 1 time and also the amount of times it occurred as well as a corresponding value on the same line as the partNumber.

The output would look like this:

( 1 0 1 1 0 0 0 0 "2125R_1.0" "136380" "" 18 0 0 0 0 0 )
( 2 0 1 1 0 0 0 0 "2125R_1.0" "128587" "" 41 0 0 0 0 0 )
( 3 0 1 1 0 0 0 0 "2125R_1.0" "138409" "" 11 0 0 0 0 0 )
( 4 0 1 1 0 0 0 0 "2125R_1.0" "110984" "" 8 0 0 0 0 0 )
( 5 0 1 1 0 0 0 0 "3216R_1.3" "114441" "" 6 0 0 0 0 0 )
( 6 0 1 1 0 0 0 0 "3216C_1.3" "2006722" "" 16 0 0 0 0 0 )
( 7 0 1 1 0 0 0 0 "3216C_1.3" "135732" "" 6 0 0 0 0 0 )

Can anyone help me with creating a dictionary to do this?

  • 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-25T00:21:41+00:00Added an answer on May 25, 2026 at 12:21 am
    foreach (string word in lineList)
    {
        if (dictionary.ContainsKey(word)
            dictionary[word]++;
        else
            dictionary[word] = 1;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sprite image for each list item (home, services and contact). I'm
I have this code: private void removeDuplicates(List<string> currentSites, List<string> visitedSites) { for (int i
I have a program that takes each item from a list and compares it
I have a list of items. For each item there are sublists. It is
I have this list: mylist = [20, 30, 25, 20, 30] After getting the
I have a question - I'm using CURL and PROXY. I'm getting list with
I have the code below for getting a list of child processes on windows
I have a custom list view that is getting data from server and changing
I have a method for getting values from database. public virtual List<TEntity> GetValues( int?
One user control is a list box where each item in the list has

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.