Inconsistent accessiblity compiler error when putting public metho

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to extend TreeView to add some of my own functionality and I
needed to put a public method but the compiler won't let me and I really
don't understand why.

I declared my class:

public class MyTree : TreeView

and then tried to add a simple method:

public void DoSomething() { }

and compiler will not let me... my method name does not conflict with
anything existing in TreeView...
 
MrNobody said:
I am trying to extend TreeView to add some of my own functionality and I
needed to put a public method but the compiler won't let me and I really
don't understand why.

I declared my class:

public class MyTree : TreeView

and then tried to add a simple method:

public void DoSomething() { }

and compiler will not let me... my method name does not conflict with
anything existing in TreeView...

"...compiler will not let me..."

Can you post a short, complete program (one that compiles) that
demonstrates this compiler error? It should be very easy if it's
nothing more than inheriting from TreeView and adding one method.

Can you also please post the exact text of the compiler error message
you're getting?
 
Has the method in question really returnin void and doesn't have any
parameters.
Form the text of the message i what guess the method is using a type as
return or parameter type that is not public. Then the method itself also
can't be public. Other users wouldn't be able to use this method.

Otherwise. look at the answer of Bruce Wood.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top