也许我还不太熟悉.NET,但我还没有看到一种令人满意的方式在.NET中轻松实现这个简单的VB6代码(假设这个代码在一个带有N CommandButtons的表单Command1()和N中数组Text1()中的Text@R_301_460@es:
Private Sub Command1_Click(Index As Integer) Text1(Index).Text = Timer End Sub
我知道它不是非常有用的代码,但它证明了控制数组在VB6中的易用性. C#或VB.NET中最简单的等价物是什么?
制作文本框的通用列表:
var text@R_301_460@es = new List<Text@R_301_460@>(); // Create 10 text@R_301_460@es in the collection for (int i = 0; i < 10; i++) { var text@R_301_460@ = new Text@R_301_460@(); text@R_301_460@.Text = "Text@R_301_460@ " + i; text@R_301_460@es.Add(text@R_301_460@); } // Loop through and set new values on text@R_301_460@es in collection for (int i = 0; i < text@R_301_460@es.Count; i++) { text@R_301_460@es[i].Text = "New value " + i; // or like this var text@R_301_460@ = text@R_301_460@es[i]; text@R_301_460@.Text = "New val " + i; }