I have 5 DataTables that needs to be converted to TXT files. Instead of creating them separately, I thought I use a for
loop. Here\'s my code:
Strin
There are not enough information in the question to know exactly what the problem is, so I'm just guessing here. Your problem is that you have five objects, that all have a method, and these method have different names. The methods return the same thing, though, DataTable
, that can be used in a loop.
If that's the case then just take out of the loop that which is different, so that in the loop remains that which is identical. Something like this:
DataTable[] fiveTables =
{
file1BLO.SelectFile1ForCSV(),
file2BLO.SelectFile2ForCSV(),
file3BLO.SelectFile3ForCSV(),
file4BLO.SelectFile4ForCSV(),
file5BLO.SelectFile5ForCSV()
}
for (int i = 1; i <= 5; i++)
{
// Use fiveTables[i] for DataTable, and i for file name
}