Add TextBox.Text to a list using a for loop

后端 未结 3 1469
再見小時候
再見小時候 2021-01-23 19:25

I am trying to take the values in the textboxes, named sequentially from 0-9, and add that to a List using a for loop. I am having problems with the syntax or something.

3条回答
  •  伪装坚强ぢ
    2021-01-23 19:33

    My understanding is that you have text boxes named amtBox1, amtBox2, etc., and what you are trying to do is sequence through them. As you point out, this is very easy in PHP. It is possible to do what you're suggesting using reflection, but that is expensive and, in any event, there's probably a better way to do what you're looking for.

    You could put all of your amount boxes into an array, and then what you have would work:

    var amtBoxes = new[] {
        amtBox1,
        amtBox2,
        amtBox3
    }
    

提交回复
热议问题