C#中76个关键字使用特色
2012-06-21 09:55
197 查看
C#中76个关键字:
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 void
while
5个在某些情况下是关键字:
get set value add remove
C#中有76个在任何情况下都有固定意思的关键字。另外还有5个在特定情况下才有固定意思的标识符。例如,value能用来作为变量名,但有一种情况例外,那就是它用作属性/索引器的set语句的时候是一关键字。
但你可以在关键字前加@来使它可以用作变量名:
int @int = 42;
不过在一般情况下不要使用这种变量名。
你也可以使用@来产生跨越几行的字符串,这对于产生正则表达式非常有用。例如:
string pattern = @"
( # start the group
abra(cad)? # match abra and optional cad
)+"; # one or more occurrences
如果你要在字符串中包含双引号,那你可以这样:
string quote = @"""quote""";
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 void
while
5个在某些情况下是关键字:
get set value add remove
C#中有76个在任何情况下都有固定意思的关键字。另外还有5个在特定情况下才有固定意思的标识符。例如,value能用来作为变量名,但有一种情况例外,那就是它用作属性/索引器的set语句的时候是一关键字。
但你可以在关键字前加@来使它可以用作变量名:
int @int = 42;
不过在一般情况下不要使用这种变量名。
你也可以使用@来产生跨越几行的字符串,这对于产生正则表达式非常有用。例如:
string pattern = @"
( # start the group
abra(cad)? # match abra and optional cad
)+"; # one or more occurrences
如果你要在字符串中包含双引号,那你可以这样:
string quote = @"""quote""";
相关文章推荐
- C#中76个关键字
- .Net (C#)Base关键字的使用
- 18个不常见的C#关键字,您使用过几个?
- C#中标点符号使用特色和注意
- C# yield 关键字 使用
- 了解何时使用 Override 和 New 关键字(C# 编程指南)
- 关于C#中关键字new override的使用(与C 4000 ++对比)
- c#编程之使用 Override 和 New 关键字进行版本控制
- C#中关键字using的三种使用方法
- 18个不常见的C#关键字,您使用过几个?
- 18个不常见的C#关键字,您使用过几个?
- C#中求任意个数的最大值 使用params关键字
- 使用 Override 和 New 关键字进行版本控制(C# 编程指南)
- 使用C# yield关键字来提高性能和可读性
- C#2.0中使用yield关键字简化枚举器的实现
- C#中指针*的使用(unsafe关键字与fixed 语句)
- C#使用OleDb连接Excel数据源编写查询语句捕获到“无法识别的关键字when”的异常
- 使用 Override 和 New 关键字进行版本控制(C# 编程指南)
- C#中SQL Server数据库连接池使用及连接字符串部分关键字使用说明
- 使用未公开关键字在 C# 中导入外部 printf 等参数数量可变函数 [1] CLR 支持