2
I am here copying a tutorial and is giving an error that I am not able to solve.
Error:
cannot implicity Convert type int to string
Code:
label_nome.Text = "Funcionario" + num_funcionario;
count_idade.Value = 18;
}
private void cmd_contratar_Click(object sender, EventArgs e)
{
FUNCIONARIOS.Add(new cl_funcionario() {
nome = label_nome.Text,
idade = (int)count_idade.Value // Erro
});
num_funcionario++;
}
I would say that
num_funcionario
is aint
and you’re trying to concatenate him with a String. It would not be the case to donum_funcionario.ToString()
?– Woss
We need you to provide the class and adjust the text as I did in the edition, this
cast
is invalid, but where he’s going I also don’t know what he gets, it’s all complicated if I don’t post the related items. As was said aToString()
can solve, but, if the problem is bigger and there is no way to know.– novic
that’s right thank you
– devilonline
Be careful not to make unnecessary conversions, careful I think you are going the wrong way.
– novic