Leading '.' or '!' cannot appear in a constant expression

Member access (.) and dictionary member access (!) require an expression specifying the element that contains the member most of the time, including constant expressions. The following declaration is not valid.

' Not valid.
Const c As String = .name

Error ID: BC30995

To correct this error

  • Specify the instance that contains the member that you want to access.

See Also

Tasks

How to: Declare an Instance of an Anonymous Type

Concepts

Object Initializers: Named and Anonymous Types

Reference

Const Statement (Visual Basic)