Grasshopper

algorithmic modeling for Rhino

Hi!

I'm new with C# and have some troubles with the Output of an Array.

Input is a variable declared as "Tree Access" and "Int". During my conditions I give value to the input Variable. When I want to write to the A-Output there comes an Error that I cannot write an Array on an Object Variable. How can I give an OutputArray?

 

private void RunScript(int Residential, int Office, int Retail, List<int> h, ref object A) 

{

    if (h[0] < 100) {A[0] = Retail; }    

else    {A[0] = Residential; }


    if (h[1] < 100) {A[1] = Office; }    

else    {A[1] = Residential; }  

}

 

Thanks for Help!!

Views: 1006

Replies to This Discussion

Hi Theodor,

 

C# is a strongly types language, so even if you assign an Array to A, you still cannot use index brackets because A is declared as System.Object.

 

What you need to do is specifically declare an array (or a List<T>, which is usually easier to work with), and then assign that variable to A at the end of your script.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks David!! Got it.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service