class's name has name same namespace 's name

T

tuanhoanganh

My program has class's name same namespace 's name.
Ex
namespace clsvoucher
public class clsvoucher
..........
end class
end namespace
Can I use Dim a as clsvoucher or I must use Dim a as clsvourcher.clsvourcher
?
Thank. Sorry for my english
 
C

Cor Ligthert

Tuanhonanganh

The secondone, however why do you not try those simple things.

Cor
 
H

Herfried K. Wagner [MVP]

tuanhoanganh said:
My program has class's name same namespace 's name.
Ex
namespace clsvoucher
public class clsvoucher
..........
end class
end namespace
Can I use Dim a as clsvoucher or I must use Dim a as
clsvourcher.clsvourcher
?

You'll have to fully qualify the type name or define a type-alias using
'Imports'.
 
C

Carlos J. Quintero [.NET MVP]

Actually it depends on where is declared the variable:

Namespace clsvoucher
Public Class clsvoucher

End Class
Public Class c1
Private m_o1 As clsvoucher.clsvoucher ' This causes error
"Type clsvoucher.clsvoucher is not defined"
Private m_o2 As clsvoucher ' This works fine
End Class
End Namespace

Namespace N2
Class c1
Private m_o As clsvoucher.clsvoucher ' This works fine

End Class
End Namespace
--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
C

Carlos J. Quintero [.NET MVP]

No without qualifying with the namespace, since you are in another
namespace.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 

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