String vs [String] in VB.Net

I am wondering what the difference is when declaring variables as such ...

Dim something as String = Nothing

and

Dim something as [String] = String.Empty

In particular, the difference between String and [String].

+4
source share
1 answer

There is no difference except that the first Nothingand the second are empty string.

You use square brackets ( [...]) around an identifier in VB.NET to tell the compiler that it should ignore the keyword.

It is often used on Enum:

Dim colors = [Enum].GetValues(GetType(Colors))

because it Enumis a keyword and type. Without parentheses that will not compile.

MSDN :

, . - , .

+4

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


All Articles