Equivalent to refer to control by variable name?

前端 未结 4 1001
北荒
北荒 2021-01-22 16:44

In VB I can loop through controls, or refer to a control by concatenating a variable to a string. Something like:

Dim I as integer
I = 1
Me[\"Textbox\" & I]         


        
4条回答
  •  隐瞒了意图╮
    2021-01-22 16:52

    int i = 1;
    this.Controls["TextBox" & i].Text = "Some text";
    

    The above code is assuming that it is in a Control/Form.

提交回复
热议问题