1
I have a list in my code that is fed as follows:
string Recursos = "E-mail, Desktop, Datasul, Aptus";
string[] RecursoArray = Regex.Split(Recursos, @"\W+\s+");
List<Ti01> ListaRecursos = new List<Ti01>();
Ti01 t1 = new Ti01();
foreach (var tarefa in RecursoArray)
{
if (!string.IsNullOrEmpty(tarefa))
{
t1.Recursos = tarefa;
if (tarefa.Equals("Datasul") || tarefa.Equals("Protheus") || tarefa.Equals("Aptus") || tarefa.Equals("SalesForce"))
{
t1.TipoRecurso = "Sistemas";
}
else
{
t1.TipoRecurso = "Infra";
}
if (tarefa.Equals("Datasul"))
{
t1.ObsRecurso = model.ObsDatasul;
}
else if (tarefa.Equals("Protheus"))
{
t1.ObsRecurso = model.ObsProtheus;
}
else
{
t1.ObsRecurso = "";
}
ListaRecursos.Add(t1);
}
But only the ULTIMO
appeal to that foreach.
In the case of the example, the resource Aptus
would be added to that list 4 vezes
, ignoring all other indexes.
Does anyone have a sense of what might be going on?
Add the
Ti01 t1 = new Ti01();
Within theforeach
– Barbetta