Variable Identifiers
- Keywords may be used as identifiers if they include “@” as a prefix (E.g. @return).
- There are four undocumented reserved keywords which are required only in rare interop scenarios:
__arglist
, __makeref
, __reftype
, and __refvalue
.
Hexadecimal Notation
- To specify a hexadecimal value, prefix the value with “
0x
” and then use any hexadecimal digit.
- E.g. 0x000A corresponds to the decimal value 10 and 0x002A corresponds to the decimal value 42.
- Each hex digit is four bits, so a byte can represent two hex digits.
int integralValue = 0x000A;
string hexValue = integralValue.ToString("X");
Namespace Alias Qualifier
- It can sometimes be necessary to reference two versions of assemblies that have the same fully-qualified type names.
- For example, when you need to use two or more versions of an assembly in the same application.
- By using an external assembly alias, the namespaces from each assembly can be wrapped inside root-level namespaces named by the alias.
- To reference two assemblies with the same fully-qualified type names, an alias must be specified at a command prompt, as follows:
/r:GridV1=grid.dll
/r:GridV2=grid20.dll
- This creates the external aliases GridV1 and GridV2.
- To use these aliases from within a program, reference them by using the
extern
keyword.
extern alias GridV1;
extern alias GridV2;
- Each
extern
alias declaration introduces an additional root-level namespace that parallels (but does not lie within) the global namespace.
- Thus types from each assembly can be referred to without ambiguity by using their fully qualified name, rooted in the appropriate namespace-alias.
- In the previous example,
GridV1::Grid
would be the grid control from grid.dll, and GridV2::Grid
would be the grid control from grid20.dll.
Escape Characters
\\'
– single quote, needed for character literals
\\"
– double quote, needed for string literals