Is it possible to hide a public method of the abstract class?

5

I have the following scenario:

public abstract class ClasseA
{
    public string[] MetodoC(string parametro, string nomeObjeto)
    {
        // ações metodo
    }        
}

public class ClasseB : ClasseA
{
    public string[] MetodoD(string nomeObjeto)
    {
        string[] Resultado;
        string Parametros = "";
        Parametros = "asdfg..." // parametros 

        Resultado = MetodoC(Parametros, nomeObjeto); 

        return Resultado;
    }

    public string[] MetodoE(string nomeObjeto)
    {
        string[] Resultado;
        string Parametros = "";
        Parametros = "12345..." // parametros 

        Resultado = MetodoC(Parametros, nomeObjeto); 

        return Resultado;
    }
}

When I instantiate ClasseB , it has methods MetodoC(...) , MetodoD(...) and MetodoE(...) .

Is there a way to display only the methods MetodoD(...) and MetodoE(...) ?

I would like MetodoC(...) to be "hidden".

    
asked by anonymous 20.08.2015 / 17:44

1 answer

6

Instead of using the public access modifier, use protected .

A protected method of ClassA will have its visibility limited to the classes that inherit it, ie within ClassB, but who instantiate ClassB will not have method visibility.

    
20.08.2015 / 17:49