Should I use this.
Imports System.IO
Dim myStream As New Stream
or this..
Dim myStream As New System.IO.Stream
Does it make any difference to performance / memory usage?
Should I use this.
Imports System.IO
Dim myStream As New Stream
or this..
Dim myStream As New System.IO.Stream
Does it make any difference to performance / memory usage?
No difference whatsoever - it's just a matter of taste and affects readability only.
By the way, CLR is not even aware of the concept of "namespaces": namespace names become prefixes to type names.
In VB.Net you have a third option:
Dim myStream As New IO.Stream
You can't do that in C#. For the IO namespace I almost always use that shortcut, since "IO." isn't that much extra to type. For most other namespaces I tend to add a using statement at the top of the file.
What is more readable to you? I always find it best to import the namespace you need so that you type names are shorter in your code.
Namespaces have no effect on memory or performance - they simply exist to prevent ambiguity between types in a global space.
Thanks muchly. Tis what I thought, but always good to get a second opinion.
Paul,