Q:

What does [String] mean in VB.NET?

Does anybody know what does the following construct mean:
    Dim s1 as [String]

What do the square brackets mean? And why does the following statement with Integer fail while the one above, with String works?
    Dim i1 as [Integer]

Thanks in advance.

A:

THe square brackets is used so that the compiler interprets it as a type, even if it would be a keyword. Imagine for example if you had a class named As:
Dim a As [As]

This is usually only used in auto generated code, so that it works with any type that you throw at it.
The reason that you can't use [Integer] is that Integer is not a data type, it's a keyword. You would have to use the corresponding data type, i.e. [Int32].

A:

Square brackets are used to create a variable that has the same name as a keyword in VB.NET. So they are more often used that way:
Dim [Integer] As Integer
Dim [String] As String

A:

In addition to the other answers:
For the case of using variable names with names the same as types: you shouldn't have to use those in your own code. If you do, you are naming your variable names incredibly poorly, and need to work on using better variable names first!

