String is a keyword. If you want to use the keyword as an identifier, you will have to bracket it. [String] is an identifier. The String keyword always refers to the System.String class, and [String] can refer to your own class called String in the current namespace. Assuming you have an Imports System , they apply to the same thing most of the time, but may be different:
Module Test Class [String] End Class Sub Main() Dim s As String = "Hello World" // works Dim s2 As [String] = "Hello World" // doesn't work End Sub End Module
The main reason for the existence of [ ] for processing keywords as identifiers is compatibility with libraries from other languages ββthat can use VB keywords as type or member names.
source share