1
I’m replacing one code with another in each row that the code is found on. But replace simply doesn’t work, goes through it and the line continues the same way. As you can see in the image below, if I use inside the immediate, it appears that it worked, but when checking the contents of the string I see that it continued the same way.
string texto = string.Empty;
int contadorCodigos = 0;
int contadorLinhas = 0;
string linha = string.Empty;
string[] linhas = new string[_linhas.Count()];
foreach (string line in _linhas)
{
linha = line;
foreach (var item in _codigos)
{
if (line.Contains(item.Key))
{
linha.Replace(item.Key, item.Value);
//line.Replace(item.Key, item.Value);
texto += $" {item.Key} - {item.Value};";
contadorCodigos++;
break;
}
}
linhas[contadorLinhas] = linha;
contadorLinhas++;
}
txtResultado.Text = texto;
txtQtdCodigosTrocados.Text = contadorCodigos.ToString();
Does anyone know what might be going on?
Thank you very much Thiago, stupid mistake on my part rsrs
– Pedro Mapelli
Honest mistake. It happens to everyone.
– Thiago Lunardi