There are currently 77 keywords defined in the C# language . These keywords, combined with the syntax of the operators and separators, form the definition of the C# language. These keywords cannot be used as names for a variable, class, or method.
abstract | as | base | bool | break |
byte | case | catch | char | checked |
class | const | continue | decimal | default |
delegate | do | double | else | enum |
event | explicit | extern | false | finally |
fixed | float | for | foreach | goto |
if | implicit | in | int | interface |
internal | is | lock | long | namespace |
new | null | object | operator | out |
override | params | private | protected | public |
readonly | ref | return | sbyte | sealed |
short | sizeof | stackalloc | static | string |
struct | switch | this | throw | true |
try | typeof | uint | ulong | unchecked |
unsafe | ushort | using | virtual | volatile |
void | while |
In addition to the keywords, C# defines a set of words that have unique meanings when they are used in certain situations. These are called contextual keywords. They include get, set, yield, value, where, and partial. Because they are not reserved words, outside their context they can be used as names for other program elements, but good practice suggests that it is better not to do so.
No comments:
Post a Comment