I have the following classes:
public class Pessoa
{
public int PessoaId { get; set; }
public string Nome { get; set; }
public DateTime DataNascimento { get; set; }
}
public class Cliente : Pessoa
{
public int ClienteId { get; set; }
}
public class Funcionario : Pessoa
{
public int FuncionarioId { get; set; }
}
I created the following method:
public Pessoa Teste(Pessoa pessoa)
{
// Bloco lógico
return pessoa;
}
What I would like to do now was to send a Funcionario
or Cliente
to the Teste
method and get them back with their Pessoa
properties changed.
The problem is that when using:
var func = new Funcionario();
func = Teste(func);
It does not work, because my func
variable is of type Funcionario
, and return in method Teste
returns Pessoa
. But since Funcionario
inherits from Pessoa
is there any way to do that?