Hashtable.Values.CopyTo()<P>Hi Guys,</P> <P>I am trying to convert the values in my hashtable to an array.&nbsp; I am using the hashtable.values.CopyTo() function but it always breaks, it doesn't seem to matter if I change my array type.</P> <P>The data in the hashtable is a [,] and i would prefer to keep it that way, however I know that I may have to change it to a double[ ] (conincendentaly I have done that) but I still get a error on the lines it doesnt fit.</P> <P>Can someone please help.&nbsp; I have pasted my code below.</P><FONT color=#0000ff size=2><FONT color=#0000ff size=2> <P>double</FONT><FONT color=#000000 size=2>[]meanR = </FONT><FONT color=#0000ff size=2>new</FONT><FONT color=#000000 size=2> </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2><FONT color=#000000>[7];</FONT></P> <P>theMeanReturn = mean.getMeanCcyReturns(TheReturns);</FONT><FONT color=#008000 size=2>//<FONT color=#0000ff><FONT color=#339966>theMeanReturn</FONT> </FONT>returned as a [,]</P></FONT><FONT size=2> <P></FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2>[] TheMeanReaturn = </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2>[];<FONT color=#008000>//parse theMeanReturns to a [ ] </FONT></P> <P></FONT><FONT color=#0000ff size=2>for</FONT><FONT size=2> (</FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> p = 0; p &lt; theMeanReturn.Length;p++)</P> <P>{</P> <P>TheMeanReaturn[p] = theMeanReturn[0,p];</P> <P>}</P> <P>theMeanReturns.Add(CurrencyPairsData,TheMeanReaturn);<FONT style="BACKGROUND-COLOR: #008000">/</FONT><FONT style="BACKGROUND-COLOR: #ffffff" color=#008000>/Take it to my hashtable</FONT></P> <P>TheMeanReaturn.Length.ToString();</P> <P>theMeanReturns.Values.CopyTo(meanR,0);<FONT color=#ff0000>//This is where i attempt to convert the data from hashtable</FONT></P> <P></FONT></FONT> <P><FONT color=#008000 size=2></P></FONT><FONT size=2>&nbsp;I <P></P> <P>I am either recieving errors that the array does not fit or that the combination is wrong, or Object cannot be stored in an array of this type.&nbsp; I really dont know what else I shoud do?</P> <P>Thanks </P> <P>HB</P></FONT>© 2009 Microsoft Corporation. Todos os direitos reservados.Thu, 19 Jun 2008 00:15:52 Z78a59047-d326-43de-8700-8874e47acf1fhttp://social.msdn.microsoft.com/Forums/pt-BR/netfxbcl/thread/78a59047-d326-43de-8700-8874e47acf1f#78a59047-d326-43de-8700-8874e47acf1fhttp://social.msdn.microsoft.com/Forums/pt-BR/netfxbcl/thread/78a59047-d326-43de-8700-8874e47acf1f#78a59047-d326-43de-8700-8874e47acf1fHarryBedihttp://social.msdn.microsoft.com/Profile/pt-BR/?user=HarryBediHashtable.Values.CopyTo()<P>Hi Guys,</P> <P>I am trying to convert the values in my hashtable to an array.&nbsp; I am using the hashtable.values.CopyTo() function but it always breaks, it doesn't seem to matter if I change my array type.</P> <P>The data in the hashtable is a [,] and i would prefer to keep it that way, however I know that I may have to change it to a double[ ] (conincendentaly I have done that) but I still get a error on the lines it doesnt fit.</P> <P>Can someone please help.&nbsp; I have pasted my code below.</P><FONT color=#0000ff size=2><FONT color=#0000ff size=2> <P>double</FONT><FONT color=#000000 size=2>[]meanR = </FONT><FONT color=#0000ff size=2>new</FONT><FONT color=#000000 size=2> </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2><FONT color=#000000>[7];</FONT></P> <P>theMeanReturn = mean.getMeanCcyReturns(TheReturns);</FONT><FONT color=#008000 size=2>//<FONT color=#0000ff><FONT color=#339966>theMeanReturn</FONT> </FONT>returned as a [,]</P></FONT><FONT size=2> <P></FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2>[] TheMeanReaturn = </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2>[];<FONT color=#008000>//parse theMeanReturns to a [ ] </FONT></P> <P></FONT><FONT color=#0000ff size=2>for</FONT><FONT size=2> (</FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> p = 0; p &lt; theMeanReturn.Length;p++)</P> <P>{</P> <P>TheMeanReaturn[p] = theMeanReturn[0,p];</P> <P>}</P> <P>theMeanReturns.Add(CurrencyPairsData,TheMeanReaturn);<FONT style="BACKGROUND-COLOR: #008000">/</FONT><FONT style="BACKGROUND-COLOR: #ffffff" color=#008000>/Take it to my hashtable</FONT></P> <P>TheMeanReaturn.Length.ToString();</P> <P>theMeanReturns.Values.CopyTo(meanR,0);<FONT color=#ff0000>//This is where i attempt to convert the data from hashtable</FONT></P> <P></FONT></FONT> <P><FONT color=#008000 size=2></P></FONT><FONT size=2>&nbsp;I <P></P> <P>I am either recieving errors that the array does not fit or that the combination is wrong, or Object cannot be stored in an array of this type.&nbsp; I really dont know what else I shoud do?</P> <P>Thanks </P> <P>HB</P></FONT>Tue, 06 Feb 2007 11:03:05 Z2007-07-31T21:22:34Zhttp://social.msdn.microsoft.com/Forums/pt-BR/netfxbcl/thread/78a59047-d326-43de-8700-8874e47acf1f#77614723-185a-4d71-81ed-89e95fbdd6f0http://social.msdn.microsoft.com/Forums/pt-BR/netfxbcl/thread/78a59047-d326-43de-8700-8874e47acf1f#77614723-185a-4d71-81ed-89e95fbdd6f0Inbar Gazithttp://social.msdn.microsoft.com/Profile/pt-BR/?user=Inbar%20GazitHashtable.Values.CopyTo()<p>If the type of the elements in the Array and the size of the array matches this works just fine.</p> <p align=left>Remember that values is an ICollection of objects. You can check the Count property to make sure you have the correct number of values and check that they are of the same correct type and this would sucsseed.</p> <p align=left><font face=Arial size=2></font> </p>Tue, 31 Jul 2007 21:22:30 Z2007-07-31T21:22:34Zhttp://social.msdn.microsoft.com/Forums/pt-BR/netfxbcl/thread/78a59047-d326-43de-8700-8874e47acf1f#edbf24fd-074c-4a3c-b3a6-d03e40cfbaafhttp://social.msdn.microsoft.com/Forums/pt-BR/netfxbcl/thread/78a59047-d326-43de-8700-8874e47acf1f#edbf24fd-074c-4a3c-b3a6-d03e40cfbaafThomas Daneckerhttp://social.msdn.microsoft.com/Profile/pt-BR/?user=Thomas%20DaneckerHashtable.Values.CopyTo()<p>Please change the names of your variables. There are three variables with nearly the same name! It makes it very very difficult to read your code. There's theMeanReturn, TheMeanReaturn and theMeanReturns. I think meanR should be a jagged array:</p> <p align=left> </p> <p align=left> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Snippet</span></div> <p align=left>double[][] meanR;</p> <p align=left> </p></div></div> <p align=left> </p><font face=Arial size=2></font> <p></p>Wed, 01 Aug 2007 12:57:42 Z2007-08-01T12:57:42Z