1
In class Lawyer implemented all Interface properties and methods Ipessoafisica, and some other class-specific properties and methods Lawyer, how to Advocate() and Oab.
How to access this method? Since in the creation of the object Lawyer i created as Testemethod below:
public interface IPessoaFisica
{
    int PessoaId { get; set; }
    string Nome { get; set; }
    IEndereco Endereco { get; set; }
    IContato Contato { get; set; }
    string Cpf { get; set; }
    string Identidade { get; set; }
    char Sexo { get; set; }
}
//Classe Concreta
public class Advogado: IPessoaFisica
{
    public int PessoaId { get; set; }
    public string Nome { get; set; }
    public IEndereco Endereco { get; set; }
    public IContato Contato { get; set; }
    public char Sexo { get; set; }
    public string Identidade { get; set; }
    public string Cpf { get; set; }
    public string Oab { get; set; }
    public void Advogar()
    {
        //Fazer qualquer coisa
    }
}
public void TestMethod1()
{
    IPessoaFisica adv = new Advogado();
    adv.Cpf = "111.111.111-11"; //OK
    adv.Nome = "José da Silva"; //OK
    adv.Advogar(); //ERRO - IPessoaFisica não contém definição de Advogar.
               // Método esta na classe concreta Advogado,e não está declarado na interface IPessoaFisica.
}
Thank you Giuliana. I know that if I do any of the options you mentioned I will be able to access the Lawyer() method. However, the idea was to be able to "plug" into Ipessoafisica any type of person. That is, a lawyer, a judge, or any other kind of physical person. But access the specific methods of the particular class. Tb do not want to declare directly the concrete class aiming to decrease the coupling.
– Léo B
Then you could declare in your interface the method exercise officiating, then you could implement it as advocate, "judge", etc... It would work for you like this?
– Giuliana Bezerra
Sounds like a good idea. :)
– Léo B
@Léob Have some problems declaring the variable as
IPessoaFisicaand then convert to the concrete type?– Jéf Bueno
Has if @Léob wants the Testmethod1 method to be polymorphic.
– Giuliana Bezerra
Always consider an interface as follows: What is common in multiple objects so that I can abstract in an interface, in this mode your interface can never have something that is unique to the final object! Very good comment @Giulianabezerra !!!
– Maurício Júnior