Grasshopper

algorithmic modeling for Rhino

I made a c# assembly in visual studio that will take in a list of numbers and check if its even or odd. Im getting this error when i input numbers in grasshopper.

Here is my solve instance :

protected override void SolveInstance(IGH_DataAccess DA)
{
List<int> nos = new List<int>();
List<string> outp = new List<string>();
string ans=null;
DA.GetDataList(0, nos);
for (int i = 0; i < nos.Count; i++)
{
     if (nos[i] % 2 == 0)
        {
          ans = "Even";
          outp.Add(ans);
        }
     else
       {
          ans = "Odd";
          outp.Add(ans);
       }
}
DA.SetDataList(0, outp);
}

Views: 1652

Replies to This Discussion

Hey...
could it be that u are setting up a number-parameter instead of a integer-parameter inside RegisterInputParams(...)?

Greets
mark

Oh...Right. Thanks.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service