views:

38

answers:

2

I am building a game and have several groups of namespaces. One is called "Engine" the other called "Game". There are several functions and variables that I only want Engine to be able to see. What do I need to do to hide certain functions (not whole classes) from the Game namespace.

+4  A: 

C# doesn't have any access modifiers which refer to namespaces.

Instead, perhaps you should put your types into different assemblies - then use the internal access modifier to limit access to the assembly in which a type or member is declared.

Additionally, if you want a type which is only relevant to one other type, you can nest it and make it private:

internal class Outer
{
    // Only the Outer class knows about Nested.
    private class Nested
    {
    }
}
Jon Skeet
Can you explain what you mean by "different assemblies".
Dave
@Dave: Separate dlls.
KMan
A: 

Use private access specifier.

KMan
Namespaces have many classes, I want to be able to talk between them but not without outside namespaces. C# doesn't have friend classes which means I need to use something else.
Dave