本文介绍了循环中类的新实例名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在循环中创建一个新的asp表行实例.

Hello,

I am creating a new instance of asp table row in a loop.

for(int i =0;i<rowCount;i++)
       {
           TableRow row = new TableRow();
           // doing something
       }



我需要的是每次循环迭代时,实例名称都应根据索引进行更改.诸如TableRow row [i] = new TableRow()之类的东西; ...这样,当我的价值发生变化时,我将获得一个新的实例,例如



What i need is everytime when my loop iterates, the instance name should change as per the index. some thing like TableRow row[i] = new TableRow(); ... so that when ever value of i changes i will get a new instance like

tablerow tr0 = new tablerow();
tablerow tr1 = new tablerow();
tablerow tr2 = new tablerow();
.
.
.
.
.
tablerow tri = new tablerow();



请让我知道我该如何实现.



Please let me know how can i achieve this .

推荐答案

sinhasourabh写道:
sinhasourabh wrote:

row [i] = new TableRow();

row[i] = new TableRow();


正是您所需要的.例如


That''s exactly what you need. e.g.

TableRow [] row = new TableRow[rowCount];
for(int i =0;i<rowcount;i++)>
{
  row[i] = new TableRow(); 
  // doing something
}


这篇关于循环中类的新实例名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 10:57