I would like to use as
and is
as members of an enumeration. I know that this is possible in VB.NET to write it like this:
Public Enum Test
[as] = 1
[is] = 2
End Enum
How do I write the equivalent statement in C#? The following code does not compile:
public enum Test
{
as = 1,
is = 2
}
Reserved keywords in C++? A reserved word is a word that cannot be used as an identifier, such as the name of a variable, function, or label – it is "reserved from use". This is a syntactic definition, and a reserved word may have no meaning. There are a total of 95 reserved words in C++.
In C programming, an enumeration type (also called enum) is a data type that consists of integral constants. To define enums, the enum keyword is used. enum flag {const1, const2, ..., constN}; By default, const1 is 0, const2 is 1 and so on.
Often found in programming languages and macros, reserved words are terms or phrases appropriated for special use that may not be utilized in the creation of variable names. For example, "print" is a reserved word because it is a function in many languages to show text on the screen.
Prefixing reserved words in C# is done with @.
public enum Test
{
@as = 1,
@is = 2
}
You will need to prefix them with the @ symbol to use them. Here is the msdn page that explains it.
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