Question

As the Name property is a string, I reckon you could assign any string value to it; on the other hand, doing this programmatically:

Pushpin rupertTPupkin@att.net = new Pushpin();

...doesn't work, due to the @ symbol, so ... what are the limitations of what can be assigned to a Pushpin's Name property?

Was it helpful?

Solution

A variable name can not have the "@" symbol in it. In C# a variable name can be any alphanumeric value as long as the first character is not a number. You can also use underscores. No other characters can be used in a variable name. The "@" has a special meaning when it comes to variables in c# and can be placed as a prefix to the variable name. When this is done the "@" symbol enables the use of keywords as identifiers, which is useful when interfacing with other programming languages. The character @ is not actually part of the identifier, so the identifier might be seen in other languages as a normal identifier, without the prefix. An identifier with an @ prefix is called a verbatim identifier

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top