2
See below my for
. Within that for
there are some IF's
. I don’t want another for
to scroll through the same list. There is a if
which validates whether IcObrigatorio == 1
and below it validates whether vlstDados[i].DsPathDocumento
is neither empty nor null. What I want if possible in the same for
to avoid having to go through the same list again, to do this validation backwards, that is, if IcObrigatorio == 0
and vlstDados[i].DsPathDocumento
equal to null or void, then I am a variável booleana
. Guys I’m getting hit on this lobe because of how I put one else
cascateado, if that’s the case. Below mine for
.
for (int i = 0; i < vlstDados.Count; i++)
{
vstrNmPessoa = vlstDados[i].NmPessoa;
if (vlstDados[i].IcObrigatorio == 1)
{
if (string.IsNullOrEmpty(vlstDados[i].DsPathDocumento))
{
if (vlstDados[i].CdTipoDocumentoSubstitui == 0)
{
vbolErro = true;
}
else
{
for (int v = 0; v < vlstDados.Count; v++)
{
if (vlstDados[i].CdTipoDocumentoSubstitui == vlstDados[v].CdTipoDocumento)
{
if (string.IsNullOrEmpty(vlstDados[v].DsPathDocumento))
{
vbolErro = true;
}
}
}
}
}
}
}
I ended up doing it the way below. I didn’t like it, because I had to repeat the same command above Else. My intention would be to see if there’s some sort of cascading Else, like:
else
else
and I don’t know if that would be better either. So I did
for (int i = 0; i < vlstDados.Count; i++)
{
vstrNmPessoa = vlstDados[i].NmPessoa;
if (vlstDados[i].IcObrigatorio == 1)
{
if (string.IsNullOrEmpty(vlstDados[i].DsPathDocumento))
{
if (vlstDados[i].CdTipoDocumentoSubstitui == 0)
{
vbolErro = true;
}
else
{
for (int v = 0; v < vlstDados.Count; v++)
{
if (vlstDados[i].CdTipoDocumentoSubstitui == vlstDados[v].CdTipoDocumento)
{
if (string.IsNullOrEmpty(vlstDados[v].DsPathDocumento))
{
vbolErro = true;
}
}
}
}
}
}
else
if (vlstDados[i].IcObrigatorio == 0 && string.IsNullOrEmpty(vlstDados[i].DsPathDocumento))
{
vbolErroDocTorObrigatorio = true;
}
}
.Icobrigatorio can take different values of 0 and 1?
– Tobias Mesquita