6 ms·
C# allows file-level namespaces so you can write namespace Math; static class Adder { public static int Add(...) { ... } } (one nesting lev
by zvrba 1y ago
C# allows file-level namespaces so you can write
namespace Math;
static class Adder {
public static int Add(...) { ... }
}
(one nesting level less). Next, elsewhere you can write
namespace Whatever;
using static Math.Adder;
class CC {
void M() {
var z = Add(10, 20); // no NS qualification needed due to using static above
}
}
Java enforces directory structure to reflect package names, and this feature is not universally popular.