Is there any difference about namespace between VB.NET and C#.

A

ad

Is there any difference about namespace between VB.NET and C#.



All functions in c# must include in a namespace.

Why I can't find namespace in the files .vb .

How VB.NET implement the concept of namespace
 
P

Peter Rilling

I believe there is a "global" or "default" namespace in the CRL. I might be
wrong, but I think VB.NET allows classes to be part of this default
namespace while c# requires all classes to be part of a namespace.
 
D

Daniel O'Connell [C# MVP]

Peter Rilling said:
I believe there is a "global" or "default" namespace in the CRL. I might
be
wrong, but I think VB.NET allows classes to be part of this default
namespace while c# requires all classes to be part of a namespace.

C# does not require anything be contained in a namespace, the default file
just happens to provide one.
 
S

Samuel R. Neff

Also, VB.NET provides a default namespace for the project and this
becomes prepended to the namespace to form the CLR namespace.

So, if you have a project with default namespace "Blinex.Charts" and
then a class:

Namespace Assets
Class LimitLine
End Class
End Namespace

Then the namespace in the CLR for referring to that class is
Blinex.Charts.Assets.LimitLine.

So in VB.NET even when you have no Namespace statement, classes are
still in a namespace defined by the project.

In contrast, the C# default namespace just defines the default value
put in the *.cs file. The *.cs file totally determines the actual
namespace though and it can be changed for each file.

HTH,

Sam


C# does not require anything be contained in a namespace, the default file
just happens to provide one.

B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
 
D

Daniel O'Connell [C# MVP]

Samuel R. Neff said:
Also, VB.NET provides a default namespace for the project and this
becomes prepended to the namespace to form the CLR namespace.

So, if you have a project with default namespace "Blinex.Charts" and
then a class:

Namespace Assets
Class LimitLine
End Class
End Namespace

Then the namespace in the CLR for referring to that class is
Blinex.Charts.Assets.LimitLine.

So in VB.NET even when you have no Namespace statement, classes are
still in a namespace defined by the project.

In contrast, the C# default namespace just defines the default value
put in the *.cs file. The *.cs file totally determines the actual
namespace though and it can be changed for each file.

I thought it was something like that, but I don't know anywhere enough about
VB to have answered. Thanks for the info.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top