Actually, I don't really have a clue about this but<br><br>Tuple key = new Tuple(new object[col, row]);<br><br>seems like it doesn't do what it probably should do, or do you intend to pass a multidimensional array to the Tuple constructor?<br>
<br>/Simon<br><br><div class="gmail_quote">On Fri, Apr 18, 2008 at 4:39 PM, Michael Foord <<a href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello all,<br>
<br>
I'm trying to use an IronPython (1.1) dictionary from C#, where the<br>
dictionary is keyed by tuples.<br>
<br>
I am printing the keys - so I can see that the values I want are in the<br>
dictionary, but I can't fetch them. I have tried various approaches -<br>
the problem seems to be that when I create a new Tuple from two integers<br>
it isn't recognised as a valid key. Any suggestions/corrections.<br>
<br>
Code below (range is a Python 'Dict'):<br>
<br>
<br>
System.Console.WriteLine("Keys: {0}", range.keys());<br>
for (int row = minRow; row < (maxRow + 1); row++)<br>
{<br>
for (int col = minCol; col < (maxCol+1); col++)<br>
{<br>
Tuple key = new Tuple(new object[col, row]);<br>
object val = range.GetValue(key);<br>
if (val != null)<br>
{<br>
try<br>
{<br>
result = (Double)FloatOps.Add(result, val);<br>
}<br>
catch (Exception e)<br>
{<br>
System.Console.WriteLine(e);<br>
}<br>
}<br>
else<br>
{<br>
System.Console.WriteLine("No Value for col<br>
{0} row {1}", col, row);<br>
}<br>
}<br>
<br>
I'm aware that the cast there is 'dubious', but as my code never reaches<br>
it it hasn't been a problem so far!<br>
<font color="#888888"><br>
Michael Foord<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
</font></blockquote></div><br>