C# 關鍵字

來源:互聯網
上載者:User

 

  關鍵字是對編譯器具有特殊意義的預定義保留標識符。 它們不能在程式中用作標識符,除非它們有一個 @ 首碼。 例如,@if 是有效標識符,但 if 不是,因為 if 是關鍵字。

本主題中的第一個表列出的關鍵字在 C# 程式的任何部分都是保留標識符。 本主題中的第二個表列出了 C# 中的內容關鍵字。 內容關鍵字僅在受限制的程式上下文中具有特殊含義,並且可在該上下文外部用作標識符。 通常,在將新關鍵字添加到 C# 語言的同時,也會將它們添加為內容關鍵字,以便避免破壞用該語言的早期版本編寫的程式。

 

abstract

as

base

bool

break

byte

case

catch

char

checked

class

const

continue

decimal

default

委託

do

double

else

enum

event

explicit

extern

false

finally

fixed

float

for

foreach

goto

if

implicit

in

in(泛型修飾符)

int

interface

internal

lock

long

命名空間

new

null

object

operator

out

out(泛型修飾符)

override

params

private

protected

public

readonly

ref

return

sbyte

sealed

short

sizeof

stackalloc

static

string

結構

switch

this

throw

true

try

typeof

uint

ulong

unchecked

unsafe

ushort

using

virtual

void

volatile

while

 
內容關鍵字

內容關鍵字用於提供代碼中的特定含義,但它不是 C# 中的保留字。 某些內容關鍵字(如 partial 和 where)在兩個或更多個上下文中具有特殊含義。

 

添加

別名

ascending

descending

dynamic

from

get

global

group

into

join

let

orderby

partial(類型)

partial(方法)

remove

select

set

value

var

where(泛型型別約束)

where(查詢子句)

yield

 
請參見

轉自MSDN 原文http://msdn.microsoft.com/zh-cn/library/x53a06bb.aspx

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.