top | item 44615657

(no title)

zvrba | 7 months 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.

discuss

order

No comments yet.