8
I am doing a dynamic sql query, in which I use lists, my problem is, how to know which last element of this list
Follow the code made so far:
List<string> campos = new List<string>();
campos.Add("id");
campos.Add("descricao");
campos.Add("Titulo");
string sql = "INSERT INTO teste( ";
foreach (string campo in campos)
{
sql += campo + ", ";//preciso saber o ultimo elemento para fechar o parênteses ao invés da vírgula
}
takes its code itself and at the end remove two characters from the sql string...
sql = sql.Substring(0, sql.Length - 2);
– FernandoNomellini