c# - Declaring an Array of Textboxes -


i'm trying declare array scores array of textboxes. doesn't have size. need declare instance variable, , instantiate in method, createtextboxes. keep getting error, "scores field used type."

namespace averagecalculator {     public partial class averagecalculator : form     {      private textbox[] scores;      public averagecalculator()     {         initializecomponent();     }      private void averagecalculator_load(object sender, eventargs e)     {         btncalculate.visible = false;     }      private void btnok_click(object sender, eventargs e)     {         int intnumtextboxes;          intnumtextboxes = convert.toint32(txtnumscores.text);          this.height = 500;         btncalculate.visible = true;         btnok.enabled = false;      }      private void createtextboxes(int number)     {         scores[number] = new scores[number];          int inttop = 150;          (int = 0; < 150; i++)         {          }     } } } 

your createtextboxes should this:

private void createtextboxes(int number) {     scores = new textbox[number];      (int = 0; < number; i++)     {         scores[i] = new textbox();     } } 

as adil suggested, list<textbox> better in case.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -