What is the meaning of the square brackets around the name of a property in the definition ?
Example :
Public Property [Date] As String
Definition of bracket. (Entry 1 of 2) 1 : an overhanging member that projects from a structure (such as a wall) and is usually designed to support a vertical load or to strengthen an angle. 2 : a fixture (as for holding a lamp) projecting from a wall or column. 3a.
Brackets are marks of punctuation—[ ]—used to interject text within other text. Types of brackets include: brackets (mostly used by Americans): [ ] square brackets (mostly used by the British): [ ]
Brackets, or braces, are a syntactic construct in many programming languages. They take the forms of "[]", "()", "{}" or "<>.". They are typically used to denote programming language constructs such as blocks, function calls or array subscripts. Brackets are also known as braces.
brack·et 1 To furnish or support with a bracket or brackets. 2 To place within or as if within brackets. 3 To classify or group together. 4 To include or exclude by establishing specific boundaries. 5 To fire beyond and short of (a target) in order to determine artillery range.
To use reserved keywords as identifiers, the brackets must be used to distinguish between the identifier and the keyword:
dim [String] As String
public sub [Stop]
end sub
On msdn it says:
Any program element — such as a variable, class, or member — can have the same name as a restricted keyword. For example, you can create a variable named Loop. However, to refer to your version of it — which has the same name as the restricted Loop keyword — you must either qualify it by preceding it with its full namespace, or enclose it in square brackets ([ ]), as in the following examples:
Reference here
This syntax allows you to use a reserved word as the name of a member or variable. Not recommended though IMHO from a code maintainability point of view (though see comments below for an alternative point of view on this particular point)!
Particularly not recommended if you're going to declare a property called "Date" as a string, but that's a separate issue...
Date is a reserved keyword in VB.NET, but can be used as a property or variable name if enclosed in square brackets:
http://msdn.microsoft.com/en-us/library/ksh7h19t(v=vs.90).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With