Keywords

suggest change

Introduction

Keywords are predefined, reserved identifiers with special meaning to the compiler. They cannot be used as identifiers in your program without the @ prefix. For example @if is a legal identifier but not the keyword if.

Remarks

C# has a predefined collection of “keywords” (or reserved words) which each have a special function. These words can not be used as identifiers (names for variables, methods, classes, etc.) unless prefixed with @.

Apart from these, C# also uses some keywords to provide specific meaning in code. They are called contextual keywords. Contextual keywords can be used as identifiers and doesn’t need to be prefixed with @ when used as identifiers.

as

goto

volatile

checked unchecked

virtual override new

stackalloc

break

const

for

async await

abstract

is

default

fixed

sealed

typeof

readonly

this

dynamic

foreach

try catch finally throw

namespace

void

ref out

float double decimal

char

params

base

operator

string

null

return

while

continue

using

ulong

uint

unsafe

int

var

lock

true false

internal

where

extern

switch

when

struct

static

if if...else if... else if

do

partial

unchecked

bool

interface

long

sizeof

in

enum

ushort

delegate

implicit

sbyte

event

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents