Subscribe

RSS Feed (xml)

Access a Program Element That Has the Same Name as a Keyword in C#

The .Net Framework allows you to use software components developed in other .NET languages from within your C# applications. Each language has its own set of keywords (or reserved words) and imposes different restrictions on the names that programmers can assign to program elements such as types, members, and variables. Therefore, it's possible that a programmer developing a component in another language will inadvertently use a C# keyword as the name of a program element. The symbol @ enables you to use a C# keyword as an identifier and overcome these possible naming conflicts. This code fragment instantiates an object of type operator (perhaps a telephone operator) and sets its volatile property to true—both operator and volatile are C# key words.
// Instantiate an operator object@operator Operator1 = new @operator();// Set the operator's volatile propertyOperator1.@volatile = true;

No comments:

Post a Comment

LocalsAdda.com-Variety In Web World

Fun Mail - Fun in the Mail