7
I am trying to change the name and email of a particular item in the list below, but I couldn’t find another way to remove the item from the list and add it again updated. There is another way to update?
class Program
{
static void Main(string[] args)
{
List<Aluno> aluno = new List<Aluno>{
new Aluno() { AlunoId = 1, Nome = "Cláudia",Email="[email protected]" },
new Aluno() { AlunoId = 2, Nome = "Pedro",Email="[email protected]" },
new Aluno() { AlunoId = 3, Nome = "Eduardo",Email="[email protected]" }
};
Console.WriteLine("==================================");
foreach (var item in aluno)
{
Console.WriteLine("ID: {0}\nNome: {1}\nEmail: {2}", item.AlunoId, item.Nome,item.Email);
Console.WriteLine("==================================");
}
Console.Read();
}
}
class Aluno
{
public int AlunoId { get; set; }
public string Nome { get; set; }
public string Email { get; set; }
}