Comparison of programming languages (associative array): Difference between revisions

Content deleted Content added
Visual Basic: copy editing
Visual Basic .NET: copy editing
Line 1,880:
</syntaxhighlight>
 
=== [[Visual Basic .NET]] ===
[[Visual Basic .NET]] uses the collection classes provided by the [[.NET Framework]].
 
====Creation====
The following code demonstrates the creation and population of a dictionary. See(see [[#C#|the C# example on this page]] for additional information.):
 
The following code demonstrates the creation and population of a dictionary. See [[#C#|the C# example on this page]] for additional information.
<syntaxhighlight lang=VBNet>
Dim dic As New System.Collections.Generic.Dictionary(Of String, String)
Line 1,893:
</syntaxhighlight>
 
An alternativealternate syntax would be to use a ''collection initializer'', which compiles down to individual calls to <code>Add</code>.:
 
<syntaxhighlight lang=VBNet>
Dim dic As New System.Collections.Dictionary(Of String, String) From {
Line 1,903 ⟶ 1,904:
 
====Access by key====
Example demonstrating access; (see [[#C# access|this section of the C# example]] for explanation):
 
Example demonstrating access; see [[#C# access|this section of the C# example]] for explanation:
<syntaxhighlight lang=VBNet>
Dim sallyNumber = dic("Sally Smart")
Line 1,916 ⟶ 1,917:
 
====Enumeration====
Example demonstrating enumeration; (see [[#C# enumeration|this section of the C# example]] for explanation):
 
Example demonstrating enumeration; see [[#C# enumeration|this section of the C# example]] for explanation:
<syntaxhighlight lang=VBNet>
' loop through the collection and display each entry.