Static Methods

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

Guest

I have a sealed public class which contains a couple of static public
methods. I pass each of these methods, among other things, an instance of a
class. When I compile this class and define each of the methods in the class
as "static private", I get no compile errors on this class. When change the
methods to "static public", they compile with an error telling me that
"Inconsistent accessibility: parameter type" and then it identifies by class
parameter I am provided and then goes on to say "is less accessible than
method" and then it identifies the "static public" method.

What is this error trying to tell me? Can I not pass an instance of a class
to a "static public" method? Why does it not object when I make the methods
"static private"?

Thanks in advance for your assistance!!!
 
Jim Heavey said:
I have a sealed public class which contains a couple of static public
methods. I pass each of these methods, among other things, an instance of a
class. When I compile this class and define each of the methods in the class
as "static private", I get no compile errors on this class. When change the
methods to "static public", they compile with an error telling me that
"Inconsistent accessibility: parameter type" and then it identifies by class
parameter I am provided and then goes on to say "is less accessible than
method" and then it identifies the "static public" method.

What is this error trying to tell me? Can I not pass an instance of a class
to a "static public" method? Why does it not object when I make the methods
"static private"?

I suspect your class isn't actually public - I suspect it's internal,
which is the default visibility for "top level" types.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 

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