Note that there are some explanatory texts on larger screens.

plurals
  1. POCombine line for line in two separate StringCollections
    primarykey
    data
    text
    <p>I am attempting to take two string collections and combine each line in both collections simultaneously to show a full file path for my user.</p> <p>Examples to help clear up confusion:</p> <ul> <li><p>String Collection 1 will contain a list of paths.<br> Example: </p> <pre><code>C:\windows\xxxx\xxx\xx, C:\Users\xxx\xxx, C:\test\xxx\xxx </code></pre></li> <li><p>String Collection 2 will contain a list of file names.<br> Example: </p> <pre><code>file.txt, asd.txt, mydll.dll </code></pre></li> </ul> <p>Each list holds the key to one another in the same line number and I just need to combine them to output them to the end user. </p> <pre><code>String Collection Line 1 + SC2 Line 1 = Path SC Line 2 + SC2 Line 2 = Path SC Line 3 + SC2 Line 3 = Path </code></pre> <p>The information is not accessible in a combined state so I will be placing the data into two separate WPF TextBoxes and then their content will be pulled into a stringcollection.</p> <p>First Collection</p> <pre><code>StringCollection lines = new StringCollection(); int lineCount = filePath.LineCount; for (int line = 0; line &lt; lineCount; line++) // Get line text and add to string collection lines.Add(filePath.GetLineText(line)); </code></pre> <p>Second Collection</p> <pre><code>StringCollection lines2 = new StringCollection(); int lineCount2 = fileName.LineCount; for (int line = 0; line &lt; lineCount; line++) // Get line text and add to string collection lines.Add(fileName.GetLineText(line)); </code></pre> <p>Any and all help is appreciated!</p> <p><strong>Edit 1</strong></p> <p>I have experimented with the ZIP command thanks to Eve but I also found an alternate route. Is there a safer route using zip compared to the code below?</p> <p>Keep in mind I will have a function to check the line counts and make sure they are the same.</p> <pre><code> StringCollection lines = new StringCollection(); int lineCount = itemIDBox.LineCount; for (int line = 0; line &lt; lineCount; line++) { string id; string rev; string combined; id = itemIDBox.GetLineText(line); rev = revBox.GetLineText(line); combined = id + @"\" + rev; lines.Add(combined); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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