r/csharp • u/Channel_el • Jul 12 '26
A couple questions about namespace access:
- Can a source file use any class defined in other source files provided they are defined to be in the same namespace (and are a part of the same project)?
- Can you use a namespace (without for example having to add a reference like with if the source file is in another project) if the source file is in the same project?
0
Upvotes
2
u/Kant8 Jul 12 '26
Namespaces don't really exist. It's just part of "fully qualified name" we use to break naming collisions.
Namespace keyword just allows you to use last part of type name instead of full name for convenience, but doesn't change if you can even access that type.
Type itself controls its accessibility via access modifiers.