Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think Grzenio's answer is correct, but I don't think you're understanding why. To elaborate, take this simple example:</p> <pre><code>string Part1 = ""; string Part2 = ""; for (int i = 0; i &lt; 2; i++) { if (i == 0) { Part1 = "Set on first iteration"; } else { Part2 = "Set on second iteration"; } } </code></pre> <p>Now, this is <strong>exactly</strong> what you've done. On the first iteration of the loop (<code>i==0</code>), you're <strong>only</strong> setting the first variable <code>Part1</code>. So the output would be:</p> <pre><code>Part1: "Set on first iteration" Part2: "" </code></pre> <p>On the second iteration (<code>i==1</code>), <code>Part2</code> will have it's value set and then it would ouput:</p> <pre><code>Part1: "Set on first iteration" Part2: "Set on second iteration" </code></pre> <p>So, taking your example:</p> <pre><code>Guid oGuid = new Guid(); // Equals all 0s by default string objectName = string.Empty; </code></pre> <p><code>objectName</code> gets set on the first iteration, but <code>oGuid</code> <strong>does not</strong>. Hence why <code>oGuid</code> remains "all zeros" (Guid.Empty).</p> <p>So, this should be the code you use:</p> <pre><code>Guid oGuid = new Guid(); string objectName = string.Empty; for (int i = 0; i &lt; lst_objectName_Guid.Count; i+=2) { // Notice how BOTH variables are assigned oGuid = new Guid(lst_objectName_Guid[i]); objectName = lst_objectName_Guid[i + 1]; // So when they're written to the console, they both have values Console.WriteLine(objectName); Console.WriteLine(oGuid); } </code></pre>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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