Dynamic Variable Name Use in C# for WinForms

前端 未结 7 1655
余生分开走
余生分开走 2021-01-13 01:28

Not sure what is the best way to word this, but I am wondering if a dynamic variable name access can be done in C# (3.5).

Here is the code I am currently looking to

7条回答
  •  长情又很酷
    2021-01-13 02:00

    for(...)
    {
         CheckBox c = this.Controls["chkCategory" + i.ToString()] as CheckBox ;
    
         c.Text = categories[i];  
    }
    

提交回复
热议问题