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
.
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 @
.
[abstract](<http://stackoverflow.com/documentation/c%23/26/keywords/2872/abstract>)
[as](<http://stackoverflow.com/documentation/c%23/26/keywords/138/as>)
[base](<http://stackoverflow.com/documentation/c%23/26/keywords/1840/base>)
[bool](<http://stackoverflow.com/documentation/c%23/26/keywords/8712/bool>)
[break](<http://stackoverflow.com/documentation/c%23/26/keywords/2858/break>)
byte
case
[catch](<http://stackoverflow.com/documentation/c%23/26/keywords/148/try-catch-finally-throw>)
[char](<http://stackoverflow.com/documentation/c%23/26/keywords/6009/char>)
[checked](<http://stackoverflow.com/documentation/c%23/26/keywords/192/checked-unchecked>)
class
[const](<http://stackoverflow.com/documentation/c%23/26/keywords/141/const>)
[continue](<http://stackoverflow.com/documentation/c%23/26/keywords/154/continue>)
[decimal](<http://stackoverflow.com/documentation/c%23/26/keywords/2873/float-double-decimal>)
[default](<http://stackoverflow.com/documentation/c%23/26/keywords/109/default>)
[delegate](<http://stackoverflow.com/documentation/c%23/26/keywords/18720/delegate>)
[do](<http://stackoverflow.com/documentation/c%23/26/keywords/12229/do>)
[double](<http://stackoverflow.com/documentation/c%23/26/keywords/2873/float-double-decimal>)
[else](<http://stackoverflow.com/documentation/c%23/26/keywords/11359/if-if-else-if-else-if>)
[enum](<http://stackoverflow.com/documentation/c%23/26/keywords/245/enum>)
[event](<http://stackoverflow.com/documentation/c%23/26/keywords/18722/event>)
explicit
[extern](<http://stackoverflow.com/documentation/c%23/26/keywords/8191/extern>)
[false](<http://stackoverflow.com/documentation/c%23/26/keywords/17113/true-false>)
[finally](<http://stackoverflow.com/documentation/c%23/26/keywords/148/try-catch-finally-throw>)
[fixed](<http://stackoverflow.com/documentation/c%23/26/keywords/59/fixed>)
[float](<http://stackoverflow.com/documentation/c%23/26/keywords/2873/float-double-decimal>)
[for](<http://stackoverflow.com/documentation/c%23/26/keywords/3722/for>)
[foreach](<http://stackoverflow.com/documentation/c%23/26/keywords/1928/foreach>)
[goto](<http://stackoverflow.com/documentation/c%23/26/keywords/193/goto>)
[if](<http://stackoverflow.com/documentation/c%23/26/keywords/11359/if-if-else-if-else-if>)
[implicit](<http://stackoverflow.com/documentation/c%23/26/keywords/16557/implicit>)
[in](<http://stackoverflow.com/documentation/c%23/26/keywords/4992/in>)
[int](<http://stackoverflow.com/documentation/c%23/26/keywords/5328/int>)
[interface](<http://stackoverflow.com/documentation/c%23/26/keywords/14354/interface>)
[internal](<http://stackoverflow.com/documentation/c%23/26/keywords/8102/internal#t=201607221603473329189>)
[is](<http://stackoverflow.com/documentation/c%23/26/keywords/139/is>)
[lock](<http://stackoverflow.com/documentation/c%23/26/keywords/6452/lock#t=201607261640175640513>)
[long](<http://stackoverflow.com/documentation/c%23/26/keywords/5329/long>)
[namespace](<http://stackoverflow.com/documentation/c%23/26/keywords/142/namespace>)
[new](<http://stackoverflow.com/documentation/c%23/26/keywords/5805/virtual-override-new>)
[null](<http://stackoverflow.com/documentation/c%23/26/keywords/6750/null>)
object
[operator](<http://stackoverflow.com/documentation/c%23/26/keywords/12604/operator>)
[out](<http://stackoverflow.com/documentation/c%23/26/keywords/184/ref-out>)
[override](<http://stackoverflow.com/documentation/c%23/26/keywords/5805/virtual-override-new>)
[params](<http://stackoverflow.com/documentation/c%23/26/keywords/2513/params>)
private
protected
public
[readonly](<http://stackoverflow.com/documentation/c%23/26/keywords/110/readonly>)
[ref](<http://stackoverflow.com/documentation/c%23/26/keywords/184/ref-out>)
[return](<http://stackoverflow.com/documentation/c%23/26/keywords/4600/return>)
[sbyte](<http://stackoverflow.com/documentation/c%23/26/keywords/18290/sbyte>)
[sealed](<http://stackoverflow.com/documentation/c%23/26/keywords/5245/sealed>)
short
[sizeof](<http://stackoverflow.com/documentation/c%23/26/keywords/5246/sizeof>)
[stackalloc](<http://stackoverflow.com/documentation/c%23/26/keywords/57/stackalloc>)
[static](<http://stackoverflow.com/documentation/c%23/26/keywords/5248/static>)
[string](<http://stackoverflow.com/documentation/c%23/26/keywords/17143/string>)
[struct](<http://stackoverflow.com/documentation/c%23/26/keywords/13023/struct#t=201607251950535084892>)
[switch](<http://stackoverflow.com/documentation/c%23/26/keywords/14353/switch>)
[this](<http://stackoverflow.com/documentation/c%23/26/keywords/2914/this>)
[throw](<http://stackoverflow.com/documentation/c%23/26/keywords/148/try-catch-finally-throw>)
[true](<http://stackoverflow.com/documentation/c%23/26/keywords/17113/true-false>)
[try](<http://stackoverflow.com/documentation/c%23/26/keywords/148/try-catch-finally-throw>)
[typeof](<http://stackoverflow.com/documentation/c%23/26/keywords/140/typeof>)
[uint](<http://stackoverflow.com/documentation/c%23/26/keywords/2874/uint>)
[ulong](<http://stackoverflow.com/documentation/c%23/26/keywords/5330/ulong>)
[unchecked](<http://stackoverflow.com/documentation/c%23/26/keywords/192/checked-unchecked>)
[unsafe](<https://stackoverflow.com/documentation/c%23/26/keywords/15630/unsafe>)
[ushort](<http://stackoverflow.com/documentation/c%23/26/keywords/18289/ushort>)
[using
(directive)](http://stackoverflow.com/documentation/c%23/52/using-directive#t=201605012059492751326)
[using
(statement)](http://stackoverflow.com/documentation/c%23/38/using-statement#t=20160501205709291959)
[virtual](<http://stackoverflow.com/documentation/c%23/26/keywords/5805/virtual-override-new>)
[void](<http://stackoverflow.com/documentation/c%23/26/keywords/2980/void>)
[volatile](<http://stackoverflow.com/documentation/c%23/26/keywords/58/volatile>)
[when](<http://stackoverflow.com/documentation/c%23/26/keywords/9258/when>)
[while](<http://stackoverflow.com/documentation/c%23/26/keywords/4396/while>)
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.
add
alias
ascending
[async](<http://stackoverflow.com/documentation/c%23/26/keywords/5993/async-await>)
[await](<http://stackoverflow.com/documentation/c%23/26/keywords/5993/async-await>)
descending
dynamic
from
get
global
group
into
join
let
[nameof](<http://stackoverflow.com/documentation/c%23/24/c-sharp-6-0-features/43/operator-nameof>)
orderby
[partial](<http://stackoverflow.com/documentation/c%23/26/keywords/19199/partial#t=201608110434471554387>)
remove
select
set
value
[var](<http://stackoverflow.com/documentation/c%23/26/keywords/4503/var>)
[where](<http://stackoverflow.com/documentation/c%23/26/keywords/8137/where-type-constraints>)
[yield](<http://stackoverflow.com/documentation/c%23/61/yield-keyword-in-c#t=201605012045372009603>)