What is the equivalent of a Java package in .Net

  • Thread starter Thread starter vivekian
  • Start date Start date
V

vivekian

Hi ,

New to dot net and C# and was wondering what is the equivalent of a
java package in dot net ?

thanks,
vivekian
 
Vivekian,

Most .NET developers do not know what a Package, is, in Java?
What is a Package in Java?

SA
 
I agree with Sharon...If I remember from my java days, it's a
namespace.

you declare the package before the class definitions:
ie
java: package mycompany.mymodule.mysubmodule
C#: namespace

And you import packages just like you import namespaces in C#:

java: imports (or import?) mycompany.mymodule.mysubmodule
c#: using mycompany.mymodule.mysubmodule

//now all the classes in that package are available

Good luck,
Jared
 
Sorry, 1st C# line should have looked like:
C#: namespace mycompany.mymodule.mysubmodule
 
You're right. Per
http://msdn.microsoft.com/vstudio/java/gettingstarted/csharpforjava/

Top-level Declarations in Java
In Java, we can group classes together with the package keyword. A
packaged class must use the package keyword in the first executable
line of the source file. Any import statements required to access
classes in other packages appear next, and then comes the class
declaration, like so:
....
C# uses the concept of namespaces to group logically related classes
through the namespace keyword. These act similarly to Java packages,
and a class with the same name may appear within two different
namespaces. To access classes defined in a namespace external to the
current one, we use the using keyword followed by the namespace name,
as shown below:

Clint
 
Clint ([email protected]) said:
You're right. Per
http://msdn.microsoft.com/vstudio/java/gettingstarted/csharpforjava/

Top-level Declarations in Java
In Java, we can group classes together with the package keyword. A
packaged class must use the package keyword in the first executable
line of the source file. Any import statements required to access
classes in other packages appear next, and then comes the class
declaration, like so:
...
C# uses the concept of namespaces to group logically related classes
through the namespace keyword. These act similarly to Java packages,
and a class with the same name may appear within two different
namespaces. To access classes defined in a namespace external to the
current one, we use the using keyword followed by the namespace name,
as shown below:

Clint

..
There is no direct correlation to a package in .NET. A package is about
naming, scoping and deployment. In .NET these functions are split across
both assemblies and namespaces. Namespaces are solely about naming,
assemblies are about deployment and scoping

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
 
Back
Top