This documentation is archived and is not being maintained.

11.7 Dictionary Member Access

Visual Studio .NET 2003

A dictionary member access expression is used to look up a member of a collection. A dictionary member access takes the form of E!I, where E is an expression that is classified as a value and I is an identifier. The type of the expression must have a default property indexed by a single String parameter. The dictionary member access expression E!I is transformed into the expression E.D("I"), where D is the default property of E. For example:

Class Keys
    Public ReadOnly Default Property Item(ByVal s As String) As Integer
            Return 10
        End Get
    End Property 
End Class

Module Test
    Sub Main()
        Dim x As Keys = new Keys()
        Dim y As Integer
        ' The two statements are equivalent.
        y = x!abc
        y = x("abc")
    End Sub
End Module

If an exclamation point is specified with no expression, the expression from the immediately containing With statement is assumed. If there is no containing With statement, a compile-time error occurs.

DictionaryAccessExpression ::= [ Expression ] ! IdentifierOrKeyword

See Also

11.6 Member Access Expressions