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 you have 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
}