C# Keywords
2015-11-19 13:41
597 查看
Keywords are predefined, reserved identifiersthat have special meanings to the compiler. They cannot be used as identifiersin
your program unless they include @ as a prefix.
For example, @if is a valid identifier but if is
not because if is a keyword.
Thefirst table in this topic lists keywords that are reserved identifiers in anypart of a C# program. The second table in this topic lists the contextualkeywords in C#. Contextual
keywords have special meaning only in a limitedprogram context and can be used as identifiers outside that context. Generally,as new keywords are added to the C# language, they are added as contextualkeywords in order to avoid breaking programs written in
earlier versions.
Contextual Keywords
A contextual keyword is used to provide a specific meaning in thecode, but it is not a reserved word in C#. Some contextual keywords, such as partial and where,
have specialmeanings in two or more contexts.
Keywords are predefined, reserved identifiersthat have special meanings to the compiler. They cannot be used as identifiersin
your program unless they include @ as a prefix.
For example, @if is a valid identifier but if is
not because if is a keyword.
Thefirst table in this topic lists keywords that are reserved identifiers in anypart of a C# program. The second table in this topic lists the contextualkeywords in C#. Contextual
keywords have special meaning only in a limitedprogram context and can be used as identifiers outside that context. Generally,as new keywords are added to the C# language, they are added as contextualkeywords in order to avoid breaking programs written in
earlier versions.
Contextual Keywords
A contextual keyword is used to provide a specific meaning in thecode, but it is not a reserved word in C#. Some contextual keywords, such as partial and where,
have specialmeanings in two or more contexts.
add | alias | ascending |
async | await | descending |
dynamic | from | get |
global | group | into |
join | let | orderby |
partial (type) | partial (method) | remove |
select | set | value |
var | where (generic type constraint) | where (query clause) |
yield | | |
相关文章推荐
- c#调用COM组件
- C#实现把指定数据写入串口
- C#动态创建button的方法
- C#中抽象方法与虚拟方法的区别
- c#中虚函数的相关使用方法
- C#使用加边法计算行列式的值
- C#实现多线程的同步方法实例分析
- C#中尾递归的使用、优化及编译器优化
- C#实现子窗体与父窗体通信方法实例总结
- C#通用邮件发送类分享
- C#中this的用法集锦
- C#.NET获取拨号连接的宽带连接方法
- C#异步绑定数据实现方法
- C#实现AddRange为数组添加多个元素的方法
- C#中Equality和Identity浅析
- C#生成饼形图及添加文字说明实例代码
- C#判等对象是否相等的方法汇总
- C#简单的向量用法实例教程
- C#实现基于链表的内存记事本实例
- C#托管堆对象实例包含内容分析