It's not really a feature of vb.net rather than .Net framework, and the
same applies for C#.
System.dll gets added automatically because ALL .Net programs use it.
There is a huge difference in compiler references from 1.1 to 2.0 and the
compiler in 2.0 seems to recognize what dll to include. For instance, the
code below will compile under 2.0 but not 1.1, using the command line "vbc
code.vb"
Imports System.Drawing
Class Test
Shared Sub Main()
Dim b as new Bitmap(10, 10)
End Sub
End Class
In .Net 1.1 you would need "vbc /reference:System.Drawing.dll test.vb"
In addition to making life easier with "smart" compilers and namespaces,
there are shortcuts.
There is no such thing as a System.Integer, yet Dim i as Integer will work
fine. Nor is Integer found in any other namespace either, but vb.net asa
few aliases. Integer is an alias for System.Int32 (or possible
System.Int64 on 64-bit systems). C# would use int as an alias for
System.Int32
When you type String, Visual Studio and compilers will browse through a
table of keywords and all referenced namespaces. If it finds String
defined it will use it. If it finds String defined several places it
won't know which one to use. The code below illustrates this with Timer
Imports System.Windows.Forms
Imports System.Timers
Class Test
Shared Sub Main()
Dim t as new Timer()
End Sub
End Class
Since the Timer class is defined in both System.Timers.Timer and
System.Windows.Forms (and they are different timers) you will have to
either remove the wrong namespace, use the fully qualified class name (ie
System.Timers.Timer) or define a new alias (shown below)
Imports System.Windows.Forms
Imports MyTimer = System.Timers.Timer
Class Test
Shared Sub Main()
Dim t as new MyTimer()
End Sub
End Class
Welcome to the wonderful world of .Net Framework