The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,805 other followers

Delphi, C#, VB.NET and SQL all have escapes to use reserved words as identifiers

Posted by jpluimers on 2014/11/04

Normally you would not want to use a reserved word as an identifier. But sometimes it can be very convenient, for instance for a code generator that wraps remoting calls or does ORM.

Both Delphi and C# have an escape for this:

The prefixes are to tell the compiler knows you really know what you are doing, and are using a reserved word as an identifier.

The cool thing: in the Run Time Type Information (Delphi) or Reflection (C# and VB.NET) you will see the names without the prefix.

Some examples from StackOverflow:

& prefix for Delphi

private &string: Integer;

Kenny Cason answered delphi – Is it possible to use reserved words for field names? – Stack Overflow.

@ prefix for C#

private long @string;

Jon Skeet answered Use the long reserved word as a variable name in C# – Stack Overflow.

[] embedding for VB.NET

Private [string] As Integer;

Tobias Wittenburg asked – Reserved Keyword in Enumeration in C# – Stack Overflow.

The VB.NET way also works in Microsoft SQL Server and Microsoft Access.

“” embedding in many SQL syntaxes


Exception: Microsoft SQL Server and Microsoft Access use [] embedding.


Some SQL implementations uses the embedding not only to allow for reserved words, but also to allow embedding spaces in identifiers.

Delphi, C# and VB.NET cannot do that, so be aware of that when performing ORM work.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: