Grasshopper

algorithmic modeling for Rhino

Hi !

please download the attached definition (it's really really simple) and let me know what's wrong. how can i get the length of a list used as input in a scriptable component?

thanks a lot!

Views: 2077

Attachments:

Replies to This Discussion

You should move this topic to the "VB and C# Corner" discussion area. You'll get the attention of the people more likely to be able to answer...

But in VB it would be something like varName.Count()
thanks taz, i did.

it seems in C# scriptable component is also "Count" although in C# tutorials seems to be "Length".
does anyone know why there is this discordance and should i expect other? where should i look for help in C# in order to be sure i find out the working commends?

thanks for the interest!
It has to do with what type your using not the language. If you just have an array, then you'd use Length. If you have a list, then you'd use Count. They both seam to do the same thing, which is return an index of the number of items within the array. Note that this integer will be the actual number of items in the array, so in order to access the last item in the array, you would have to do something like myList(myList.Count -1)
i thought list and array are different names for the same thing. thanks for clearing that up.
one short question, if you will: what's the equivalent of Writeln in C# ??
thanks a bunch!
Yes and no. At a certain level, the are conceptually the same thing, and they are in fact related, but they are not interchangable. An array is a relatively "primitive" data type. Therefore, there are only a limited number of methods that are exposed to an array. A list actually inherits from an array (I believe), but adds a lot of functionality which makes things like adding and removing items much easier. Unless required by a method or function, I almost always try to work with lists because they are a bit easier to manage.

What I wrote there could be used with C#, although its obviously not a full valid statement. In terms of dealing with C# and the dotNET framework, the methods and objects are going to be exactly the same. Its just the syntax surrounding those methods which is going to be different from VB. Here's a link that goes over a lot of the syntax differences. http://www.harding.edu/fmccown/vbnet_csharp_comparison.html
cool! thanks for the clarification!
i actually prefer C#, since i did some scripting in MEL and Javascript (for Illustrator) and C# is more similar to those languages.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service