Possible Duplicate:
What does [String] mean in VB.NET?
Dim assem As [Assembly] = [Assembly].GetExecutingAssembly()
Dim assem As Assembly = Assembly.GetExecutingAssembly()
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Square braces in VB.NET are used to allow for literal naming, even if the identifier might be a keyword in VB.NET. Generally, these are more prevalent in generated code, since there’s no point in doing it unless the word actually is a keyword.
In this case, there is no difference. What square braces allow you to do would be to, say, name a class the same as a keyword in VB.NET. For example,
This would allow you to name your class
Dim, which would ordinarily give you an error sinceDimis a keyword.Likewise, you can use it for variable names:
Here, instead of on the type name, we’re using it on the variable name. Same concept.
However, if you’re doing this, then it’s generally a code smell; it’s usually a better idea to find a name that isn’t a keyword so that people using your class don’t have to enclose the name in braces.