Porting, Python to C# - How can I iterate a tuple over a tuple?
<p>I'm port a Python project over to C#.</p>

<p>So far I've run into this problem, is there any way I could port this to C#?</p>

<pre><code>verts = (-1,-1,-1),(1,-1,-1),(1,1,-1),(-1,1,-1),(-1,-1,1),(1,-1,1),(1,1,1),(-1,1,1)
edges = (0,1),(1,2),(2,3),(3,0),(4,5),(5,6),(6,7),(7,4),(0,4),(1,5),(2,6),(3,7)

for edge in edges:
    for x,y,z in (verts[edge[0]],verts[edge[1]]):
        [...]
</code></pre>

<p>I've tried this,</p>

<pre><code>verts.Add(new List&lt;string&gt; { "-1,-1,-1" });
verts.Add(new List&lt;string&gt; { "1,-1,-1" });
verts.Add(new List&lt;string&gt; { "1,1,-1" });
verts.Add(new List&lt;string&gt; { "-1,1,-1" });
verts.Add(new List&lt;string&gt; { "-1,-1,1" });
verts.Add(new List&lt;string&gt; { "1,-1,1" });
verts.Add(new List&lt;string&gt; { "1,1,1" });
verts.Add(new List&lt;string&gt; { "-1,1,1" });

edges.Add(new List&lt;string&gt; { "0,1" });
edges.Add(new List&lt;string&gt; { "1,2" });
edges.Add(new List&lt;string&gt; { "2,3" });
edges.Add(new List&lt;string&gt; { "3,0" });
edges.Add(new List&lt;string&gt; { "4,5" });
edges.Add(new List&lt;string&gt; { "5,6" });
edges.Add(new List&lt;string&gt; { "6,7" });
edges.Add(new List&lt;string&gt; { "7,4" });
edges.Add(new List&lt;string&gt; { "0,4" });
edges.Add(new List&lt;string&gt; { "1,5" });
edges.Add(new List&lt;string&gt; { "2,6" });
edges.Add(new List&lt;string&gt; { "3,7" });

foreach (List&lt;string&gt; vert in verts)
        {

            [...]
        }

        List&lt;string&gt; lines1 = new List&lt;string&gt;();
        List&lt;string&gt; lines2 = new List&lt;string&gt;();

        foreach (List&lt;string&gt; edge in edges)
        {
            int edge1 = int.Parse(edge[0].Split(',')[0]);
            int edge2 = int.Parse(edge[0].Split(',')[1]);

            int x;
            int y;
            int z;

            foreach (int vert in verts[edge1])
            {
                [...]
            }
        }
</code></pre>

<p>So now I am getting very confused, lot's of bugs, here any there.
I seems over complicated and impractical.</p>

<p>I hope someone can help me :)</p>

<p>If you need any more information, just leave a comment, If it's hard to read, again just leave a comment.</p>

<p>~Coolq</p>

<p>This is one way you could go about doing it...</p>

<pre><code>        var verts = new[]
        {
            new Tuple&lt;int,int,int&gt; (-1,-1,-1 ),
            new Tuple&lt;int,int,int&gt; (1,-1,-1 ),
            new Tuple&lt;int,int,int&gt; (1,1,-1 ),
            new Tuple&lt;int,int,int&gt; (-1,1,-1 ),
            new Tuple&lt;int,int,int&gt; (-1,-1,1 ),
            new Tuple&lt;int,int,int&gt; (1,-1,1 ),
            new Tuple&lt;int,int,int&gt; (1,1,1 ),
            new Tuple&lt;int,int,int&gt; (-1,1,1 )
        };
        var edges = new[]
        {
            new Tuple&lt;int,int&gt;(0,1),
            new Tuple&lt;int,int&gt;(2,2),
            new Tuple&lt;int,int&gt;(2,3),
            new Tuple&lt;int,int&gt;(3,0),
            new Tuple&lt;int,int&gt;(4,5),
            new Tuple&lt;int,int&gt;(5,6),
            new Tuple&lt;int,int&gt;(6,7),
            new Tuple&lt;int,int&gt;(7,4),
            new Tuple&lt;int,int&gt;(0,4),
            new Tuple&lt;int,int&gt;(1,5),
            new Tuple&lt;int,int&gt;(2,6),
            new Tuple&lt;int,int&gt;(3,7)
        };

        foreach(var edge in edges)
        {
            var edge1 = edge.Item1;
            var edge2 = edge.Item2;

            int x, y, z;//not sure why you need these?

            foreach(var vert in new[] { verts[edge1].Item1, verts[edge1].Item2, verts[edge1].Item3 })
            {
                //[...]
            }
        }
</code></pre>

c# python 3d port