Sunday, February 19, 2012

How can I generate variables automatically?

Hi there

I need to generate some variables , like var1, var2, var3 ...

It's determined by how many records in my database.

I want to write a for() to do this. But how?

For example

for(int i=0; i<datatable.rows.count; i++)
{
String vari = new String;
}

This is not a right way in C#, does anyone know how to?

Thanks!!!

int _intTotalRowCount=0;

_intTotalRowCount=DataBaseTable.RowsCount;

string _strVar ="";for (int _intCount = 0; _intCount <_intTotalRowCount; _intCount++)

{

_strVar = _strVar+","+ "Var" +_intCount.ToString();

}

Label1.Text= _strVar;

No comments:

Post a Comment