method accessibility

  • Thread starter Thread starter Francisco K. do Amaral
  • Start date Start date
F

Francisco K. do Amaral

Hi,

How can I make a method visible only for classes from the same namespace??

thanks
 
How can I make a method visible only for classes from the same
namespace??

You can't.

But you can make your classes and/or members only visible within the same
assembly (dll) with the "internal" keyword (C#).

You can also limit visibility to itself and all derived classes using the
"protected" keyword (C#).
 
Francisco K. do Amaral said:
How can I make a method visible only for classes from the same namespace??

You can't, I'm afraid. Namespaces don't have any effect on
accessibility.
 
What you CAN do is look at the call stack, see who is calling you, and throw
an exception if not from the correct namespace. Not pretty, not elegant,
but if you have to do it, you have to do it.
 
Back
Top