Note that there are some explanatory texts on larger screens.

plurals
  1. PODictionary Checking
    text
    copied!<p>I have a list and I am getting each item in the list in a <code>foreach</code> loop.</p> <pre><code> private void saveButton_Click(object sender, EventArgs e) { if (saveFile1.ShowDialog() == DialogResult.OK) { StreamWriter sw = new StreamWriter(saveFile1.FileName); int i = 1; Dictionary&lt;string, int&gt; dictionary = new Dictionary&lt;string, int&gt;(); 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++; } } </code></pre> <p>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.</p> <p>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.</p> <p>The output would look like this:</p> <pre><code>( 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 ) </code></pre> <p>Can anyone help me with creating a dictionary to do this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload