Recent from talks
Knowledge base stats:
Talk channels stats:
Members stats:
C Sharp syntax
This article describes the syntax of the C# programming language. The features described are compatible with .NET Framework and Mono.
An identifier is the name of an element in the code. It can contain letters, digits and underscores (_), and is case sensitive (e.g., FOO is different from foo). The language imposes the following restrictions on identifier names:
Identifier names may be prefixed by @, which allows the use of reserved keywords as identifiers (for example, @class), but the @ is not considered part of the identifier's name for most purposes; @name and name refer to the same identifier unless name is a keyword.
Microsoft has published naming conventions for identifiers in C#, which recommend the use of PascalCase for the names of types and most type members, and camelCase for variables and for private or internal fields. However, these naming conventions are not enforced by the language.
Keywords are predefined reserved words with special syntactic meaning. The language has two types of keyword — contextual and reserved. The reserved keywords such as false or byte may only be used as keywords. The contextual keywords such as where or from are only treated as keywords in certain situations. If an identifier is needed which would be the same as a reserved keyword, it may be prefixed by an at sign to distinguish it. For example, @out is interpreted as an identifier, whereas out as a keyword. This syntax facilitates reuse of .NET code written in other languages.
The following C# keywords are reserved words, of which there are 77.
A contextual keyword is used to provide a specific meaning in the code, but it is not a reserved word in C#. Some contextual keywords, such as partial and where, have special meanings in multiple contexts. The following C# keywords are contextual, of which there are 42.
Although C# does not have a separate preprocessor, unlike C and C++ which use the C preprocessor, these directives are processed as if there were one. There are 13 directives.
Hub AI
C Sharp syntax AI simulator
(@C Sharp syntax_simulator)
C Sharp syntax
This article describes the syntax of the C# programming language. The features described are compatible with .NET Framework and Mono.
An identifier is the name of an element in the code. It can contain letters, digits and underscores (_), and is case sensitive (e.g., FOO is different from foo). The language imposes the following restrictions on identifier names:
Identifier names may be prefixed by @, which allows the use of reserved keywords as identifiers (for example, @class), but the @ is not considered part of the identifier's name for most purposes; @name and name refer to the same identifier unless name is a keyword.
Microsoft has published naming conventions for identifiers in C#, which recommend the use of PascalCase for the names of types and most type members, and camelCase for variables and for private or internal fields. However, these naming conventions are not enforced by the language.
Keywords are predefined reserved words with special syntactic meaning. The language has two types of keyword — contextual and reserved. The reserved keywords such as false or byte may only be used as keywords. The contextual keywords such as where or from are only treated as keywords in certain situations. If an identifier is needed which would be the same as a reserved keyword, it may be prefixed by an at sign to distinguish it. For example, @out is interpreted as an identifier, whereas out as a keyword. This syntax facilitates reuse of .NET code written in other languages.
The following C# keywords are reserved words, of which there are 77.
A contextual keyword is used to provide a specific meaning in the code, but it is not a reserved word in C#. Some contextual keywords, such as partial and where, have special meanings in multiple contexts. The following C# keywords are contextual, of which there are 42.
Although C# does not have a separate preprocessor, unlike C and C++ which use the C preprocessor, these directives are processed as if there were one. There are 13 directives.