What is the difference between Dim s As String and Dim s As [String]?

What's the difference between:

Dim s As String

and

Dim s As [String]
+3
source share
4 answers

There is no difference.

In VB, you can wrap the identifier in parentheses to make it be parsed as an identifier, not a keyword.

For example, you can write

Dim [If], [As], [Dim]

without any syntax errors.

The brackets have no effect, except to indicate that the identifier is not a keyword, someVarand therefore [someVar]identical.

+5
source

Technically, there is no difference. Dim s As Stringcoincides withDim s As [String]

+3
source

. , , , .

, :

Dim [String] as String

, .

+2
source

There are no functional differences in the hosted code.

You can use square brackets to declare a variable with the same name as the VB.NET keyword. Given a variable named "Loop" (reserved keyword in VB):

Loop.Visible = True 'Causes an error.
[Loop] .Visible = True 'Sets the Visible property of the variable named "Loop".

This example is provided on the MSDN page in the subject .

+2
source

Source: https://habr.com/ru/post/1741705/


All Articles