Namespaces

P

Pierre

Hi

I am trying to understand how namespaces work in VB.NET. The program works
partly, i.e. the first two writeline statements work. With the other ones I
get problems, VB doesn't seem to accept my Imports statements. Can someone
tell me what I am doing wrong is this program?

Imports System

Imports GeefMe = One.Eleven.Gimme ' alias voor class

Imports EenEenEen = One.Eleven ' alias voor namespace

Imports One.Twelve

Namespace One

Namespace Eleven

Public Class Gimme

Public Function GimmeAnA() As String

Return "A"

End Function

End Class

End Namespace

Namespace Twelve

Public Class Gimme

Public Function GimmeA1() As Integer

Return 1

End Function

End Class

End Namespace

End Namespace

Class app

'Module Module1

Shared Sub Main()

Dim a As One.Eleven.Gimme = New One.Eleven.Gimme

Console.WriteLine(a.GimmeAnA)

Dim n As One.Twelve.Gimme = New One.Twelve.Gimme

Console.WriteLine(n.GimmeA1)

Dim b As GeefMe = New GeefMe

Console.WriteLine(b.GimmeAnA)

Dim c As EenEenEen.Gimme = New EenEenEen.gimme

Console.WriteLine(c.GimmeAnA)

Dim d As Gimme = New Gimme

Console.WriteLine(d.GimmeA1)

End Sub

'End Module

End Class
 
S

Scott M.

Before you can use Import to import a namespace, you must have a reference
to the assembly that contains that namespace. Do you?
 
P

Pierre

That's what I finally did and it worked fine. But when I wrote the same code
in C# I didn't had to do that, that's why I was puzzled.
 

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