Difference between namespace in C# and package in Java

前端 未结 6 537
日久生厌
日久生厌 2020-11-28 20:32

What is the difference (in terms of use) between namespaces in C# and packages in Java?

6条回答
  •  悲&欢浪女
    2020-11-28 21:04

    There are a few details that differ.

    In Java the directory structure should match the package structure. No such restriction in C#.

    In C# you can have multiple namespaces in one file. In Java one file belongs to one package (see previous).

    Java has default/package accessibility. C# internal accessibility goes in assemblies.

    If you use VS and Eclipse and let them structure the project, then you will not feel the differences much.

提交回复
热议问题