Grasshopper

algorithmic modeling for Rhino

here's the code:

//List _A = new List();

//int i,j;
// for(i = 0;i < x.Count - 1;i++) { Print("a" + x[i]); }

Print("this is not working");

/*
for(i = 0;i < x.count - 1;i++) {
double sum = 0;
for(j = 0;j < i;j++) {
sum = sum + x[j];
}
_A.Add(sum);
}
A = _A;
*/


sorry for the bad formatting, but anyway.
you can see everything is commented out except the very explicative print statement.
this is what pops out:'
The best overloaded method match for 'System.Collections.Generic.List.Add(double)' has some invalid arguments
Argument '1': cannot convert from '' to 'double


This shouldn't happen since everything concerned with lists is commented. And if not, what am i doing wrong? Seems to me list has some trouble...
trying to do the same thing in vb.net works nicely. but still wondering why the c sharp thing doesn't do its stuff properly...

Views: 533

Replies to This Discussion

I had the same problem a while ago, my solution was to change the hint of the input list "x" from double to Object and then cast the items back to double like so: sum = sum + (double) x[j];

Hope it works out for you to.
/Tobias
hey tobias, it works :) so thanks a bunch for the workaround. i wonder why this is happening, but it's minor so i don't really care but maybe david will, who knows.
anyway, i just noticed that in my post there are some essential pieces missing, since the "<" and ">" signs are missing and everything in between. so what i was doing up there was declaring a list of doubles, but ning's html parser seems to consider them some sort of tags and not pop them up. you got the picture anyway, so really thanks for the help!
Dimitrie, if I am not mistaken, you can add "yourcodehere" markup tags to have NING preserve your code in the same format...I think...give it a try?
Luis
woops, I can't even write it in :) Do you know what I mean?
try writing this all together without the spaces...
< code > you code here < / code >


List< double > thisisatest = new List< double >();

while(1==1) {
Print("thanks louis!");
}
/*i think i got it now. quite new and unexperienced in this ning stuff */
Thanks for the tip. I've been using italic all this time.
I'm glad it worked and I hope David will have a look at it when he gets back. It seems like there aren't that many of us using C# so I guess there are more hidden bugs in the C# component than in the VB one.
Hello Dimitie, it seems to me that you are trying to use the generic C# List with a non-generic collection. Try using the non-generic ArrayList. I'll have a deeper look at it later today. For now, I hope it helps.
Thanks Luis for the < code > tag!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service