Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the meaning of the brackets in Property definition?

Tags:

vb.net

What is the meaning of the square brackets around the name of a property in the definition ?

Example :

Public Property [Date] As String 
like image 223
Pierre Watelet Avatar asked Apr 16 '12 12:04

Pierre Watelet


People also ask

What is the meaning of bracket in construction?

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.

What are brackets in writing?

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): [ ]

What are brackets in C?

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.

What does Bracken mean in English?

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.


3 Answers

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

like image 109
Arion Avatar answered Sep 20 '22 00:09

Arion


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...

like image 29
David M Avatar answered Sep 24 '22 00:09

David M


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

like image 40
Anlo Avatar answered Sep 22 '22 00:09

Anlo