Paul Laudeman commented on my Verbatim Identifier post on how to differentiate identifiers from keywords in VB.NET. I didn't want this to be lost in the comments section of the post, so I am reproducing his comment in its entirety.
For anyone who is interested, the way to escape keywords in Visual Basic .NET is with brackets enclosing the keyword. For example:
Public Property MyVariable as MyEnumType
Get
Return _myVariableType
End Get
Set(ByVal Value As CalculationType)
If (Not [Enum].IsDefined(Value.GetType, Value)) Then
Throw New ArgumentException("Specified type is not valid.")
End If
_myVariableType = Value
End Set
End Property
(notice the brackets around the keyword Enum).
Maybe it's the fact that I've been buried in T-SQL for the last 3 weeks, but this is the same way T-SQL differentiates keywords from table and column names (just like the @symbol in my original post). Is T-SQL something that Microsoft uses as the default answer to issues like this? Or is it some overriding MS scheme? Maybe soon we'll all be writing SELECT @variable1 = MyVariable.
Posted
08-25-2003 8:05 PM
by
Darrell Norton