Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I am creating a new instance of asp table row in a loop.
C#
for(int i =0;i<rowCount;i++)
       {
           TableRow row = new TableRow();
           // doing something
       }


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
C#
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 .
Posted

1 solution

sinhasourabh wrote:
row[i] = new TableRow();

That's exactly what you need. e.g.
C#
TableRow [] row = new TableRow[rowCount];
for(int i =0;i<rowcount;i++)>
{
  row[i] = new TableRow(); 
  // doing something
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900