This is almost too basic to ask...
Using the Weak-stock symbol rotation script as an example, one adds paired info (symbol, Value) into a list as follows:
CODE:
Please log in to see this code.
etc.
1) If one needs to retrieve and/or copy those values later one, how does one do that?
My attempt to retrieve them, and also transfer them to another list, have failed:
CODE:
Please log in to see this code.
2) Related question: To copy some of the (paired) items from one list to another list, it seems you can't use the Copy method as that apparently transfers from a List to an array (so my readings tell me). So one has to copy the values one holder by one holder, as in the (failed) example above?
Size:
Color:
In this particular case, you could've used .CopyTo and .AddRange (untested):
CODE:
Please log in to see this code.
Size:
Color:
Thanks, Eugene. I will check it out.
Meanwhile, I do want to know how to retrieve individual values (sym and/or value) from a list at some index value[w], say to print out or whatever. Can you help with that?
Size:
Color:
I suggest checking out the MSDN/dotnetperls/Google et al. first with general C# questions.
Size:
Color:
I already spent > 1 day doing that. They all give examples of simple, one-item lists which doesn't help in this case. Its only when I was unable to find the answer that I posed the question.
There is no published rotation script that can help out either.
Size:
Color:
CODE:
Please log in to see this code.
Size:
Color:
Hi Eugene,
With your mod, I am getting the following
Runtime error: At least one object must implement IComparable...
Size:
Color:
Check your syntax carefully.
By the way, code in 1) could be simplified:
CODE:
Please log in to see this code.
Size:
Color:
Thanks for the tip.
BTW, I realized the cause of the error was this lower down in the script:
BuyList.Sort();
When I changed it to
BuyList.Sort(this);
the error goes away. Can you enlighten me as to why this is so? (last question)
Size:
Color:
Never mind, I figured out what 'this' is for.
Thank you very much for all the help!
Size:
Color:
I guess because your iHolder doesn't implement the IComparable interface. That's why the need to provide a Comparison type.
Size:
Color: