I've got a little problem. In my program i need a list of SqlCommand objects. So there is a piece of code:
List<SqlCommand> commands;
int i = 0;
foreach (string komenda in komendy)
{
commands.ElementAt<SqlCommand>(i) = new SqlCommand(komenda, dostep());
i++;
}
where komendy is a list of string with command strings and function dostep()
is returning connection (SqlConnection
object).
I've got an error: The left-hand side of an assignment must be a variable, property or indexer for commands.ElementAt< SqlCommand >(i) and i really don't understand why.