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

Asked

Viewed 75 times

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 urge you to ClasseB, she presents of the methods MetodoC(...), MetodoD(...) and MetodoE(...).

There is a way to present only the methods MetodoD(...) and MetodoE(...)?

I would like the MetodoC(...) was "hidden".

1 answer

6


Instead of using the access modifier public, utilize protected.

A method protected Classea’s visibility will be limited to the classes that inherit it, that is, within Classeb, but who instantiate Classeb will not have visibility of the method.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.