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
2010-09-21 10:28:03
Can you explain what you mean by "different assemblies".
Dave
2010-09-21 10:41:35
@Dave: Separate dlls.
KMan
2010-09-21 10:59:25
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
2010-09-21 10:47:10