c# - I made a list of my class. How do i access that class by index? -


heres code:

namespace visual_debugger_beta {      public partial class form1 : form     {          public form1()         {             initializecomponent();             label1.text = "input modules (" + input_hierarchy.items.count + " items)";             label2.text = "output modules (" + output_hierarchy.items.count + " items)";         }          private void form1_load(object sender, eventargs e)         {          }          private void exittoolstripmenuitem_click(object sender, eventargs e)         {             application.exit();         }          private void openimagetoolstripmenuitem_click(object sender, eventargs e)         {             //open image , put image box.             openfiledialog ofd = new openfiledialog();             ofd.filter = "png (*.png)|*.png|jpg (*.jpg)|*.jpg|bmp (*.bmp)|*.bmp";              if (ofd.showdialog() == dialogresult.ok && ofd.filename.length > 0)             {                 picturebox1.sizemode = pictureboxsizemode.zoom;                 picturebox1.image = image.fromfile(ofd.filename);             }         }          private void picturebox1_click(object sender, eventargs e)         {          }          private void projecttoolstripmenuitem_click(object sender, eventargs e)         {             //new project             picturebox1.image = null;         }          private void inputtoolstripmenuitem_click(object sender, eventargs e)         {             //add input             input_hierarchy.items.add(new mod_input(false, true));             label1.text = "input modules (" + input_hierarchy.items.count + " items)";         }          private void outputtoolstripmenuitem_click(object sender, eventargs e)         {             //add output             output_hierarchy.items.add(new mod_output(false, true));             label2.text = "output modules (" + output_hierarchy.items.count + " items)";         }          private void button1_click(object sender, eventargs e)         {             input_hierarchy.items.clear();             label1.text = "input modules (" + input_hierarchy.items.count + " items)";         }          private void button2_click(object sender, eventargs e)         {             output_hierarchy.items.clear();             label2.text = "output modules (" + output_hierarchy.items.count + " items)";         }          public void eventsupdate()         {             bool a;             bool t;             = input_hierarchy.selecteditem.getisactive();          }     }      public class mod_input     {         public static bool isactive = false;         public static bool toggle = true;          public bool getisactive()         {             return isactive;         }          public bool gettoggle()         {             return toggle;         }          public mod_input(bool a, bool t)         {             isactive = a;             toggle = t;         }     }      public class mod_output     {         public bool isactive = false;         public bool toggle = true;          public mod_output(bool a, bool t)         {             isactive = a;             toggle = t;         }     } } 

now, have 1 error, , doesn't find getisactive() did code. know takes 5min solve cant.

use this

var =input_hierarchy.selecteditem != null ?     ((mod_input)input_hierarchy.selecteditem).getisactive() : false 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -