您的位置:首页 > 编程语言 > C#

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""";
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  关键字