<s>
This	O
article	O
describes	O
the	O
syntax	O
of	O
the	O
C#	B-Application
programming	O
language	O
.	O
</s>
<s>
The	O
features	O
described	O
are	O
compatible	O
with	O
.NET	B-Application
Framework	I-Application
and	O
Mono	B-Application
.	O
</s>
<s>
Microsoft	O
has	O
published	O
naming	O
conventions	O
for	O
identifiers	O
in	O
C#	B-Application
,	O
which	O
recommends	O
the	O
use	O
of	O
PascalCase	O
for	O
the	O
names	O
of	O
types	O
and	O
most	O
type	O
members	O
,	O
and	O
CamelCase	O
for	O
variables	O
and	O
for	O
private	O
or	O
internal	O
fields	O
.	O
</s>
<s>
This	O
syntax	O
facilitates	O
reuse	O
of	O
.NET	B-Application
code	O
written	O
in	O
other	O
languages	O
.	O
</s>
<s>
The	O
following	O
C#	B-Application
keywords	O
are	O
reserved	O
words	O
:	O
</s>
<s>
A	O
contextual	O
keyword	O
is	O
used	O
to	O
provide	O
a	O
specific	O
meaning	O
in	O
the	O
code	O
,	O
but	O
it	O
is	O
not	O
a	O
reserved	O
word	O
in	O
C#	B-Application
.	O
</s>
<s>
The	O
following	O
C#	B-Application
keywords	O
are	O
contextual	O
:	O
</s>
<s>
Starting	O
in	O
C#	B-Application
7.0	O
,	O
the	O
underscore	O
symbol	O
can	O
be	O
used	O
to	O
separate	O
digits	O
in	O
number	O
values	O
for	O
readability	O
purposes	O
.	O
</s>
<s>
The	O
compiler	B-Language
ignores	O
these	O
underscores	O
.	O
</s>
<s>
It	O
cannot	O
be	O
put	O
at	O
the	O
beginning	O
(	O
)	O
or	O
the	O
end	O
of	O
the	O
value	O
(	O
or	O
)	O
,	O
next	O
to	O
the	O
decimal	B-Algorithm
in	O
floating	B-Algorithm
point	I-Algorithm
values	I-Algorithm
(	O
)	O
,	O
next	O
to	O
the	O
exponent	O
character	O
(	O
)	O
,	O
or	O
next	O
to	O
the	O
type	O
specifier	O
(	O
)	O
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Language
3.0	I-Language
.	O
</s>
<s>
C#	B-Language
3.0	I-Language
introduced	O
type	O
inference	O
,	O
allowing	O
the	O
type	O
specifier	O
of	O
a	O
variable	O
declaration	O
to	O
be	O
replaced	O
by	O
the	O
keyword	O
var	O
,	O
if	O
its	O
actual	O
type	O
can	O
be	O
statically	O
determined	O
from	O
the	O
initializer	O
.	O
</s>
<s>
Curly	O
braces	O
are	O
used	O
to	O
signify	O
a	O
code	O
block	O
and	O
a	O
new	O
scope	B-Language
.	O
</s>
<s>
Class	O
members	O
and	O
the	O
body	O
of	O
a	O
method	B-Language
are	O
examples	O
of	O
what	O
can	O
live	O
inside	O
these	O
braces	O
in	O
various	O
contexts	O
.	O
</s>
<s>
Inside	O
of	O
method	B-Language
bodies	O
you	O
can	O
use	O
the	O
braces	O
to	O
create	O
new	O
scopes	O
like	O
so	O
:	O
</s>
<s>
A	O
C#	B-Application
application	O
consists	O
of	O
classes	O
and	O
their	O
members	O
.	O
</s>
<s>
The	O
entry	O
point	O
of	O
the	O
C#	B-Application
application	O
is	O
the	O
method	B-Language
called	O
Main	O
.	O
</s>
<s>
There	O
can	O
only	O
be	O
one	O
,	O
and	O
it	O
is	O
a	O
static	O
method	B-Language
in	O
a	O
class	O
.	O
</s>
<s>
The	O
method	B-Language
usually	O
returns	O
void	O
and	O
is	O
passed	O
command-line	O
arguments	O
as	O
an	O
array	B-Application
of	O
strings	O
.	O
</s>
<s>
The	O
main	O
method	B-Language
is	O
also	O
allowed	O
to	O
return	O
an	O
integer	O
value	O
if	O
specified	O
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Application
7.1	O
.	O
</s>
<s>
Asynchronous	O
Tasks	O
can	O
be	O
awaited	O
in	O
the	O
Main	O
method	B-Language
by	O
declaring	O
it	O
to	O
return	O
type	O
Task	O
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Application
9.0	O
.	O
</s>
<s>
Similar	O
to	O
in	O
scripting	O
languages	O
,	O
top-level	O
statements	O
removes	O
the	O
ceremony	O
of	O
having	O
to	O
declare	O
the	O
Program	O
class	O
with	O
a	O
Main	O
method	B-Language
.	O
</s>
<s>
This	O
was	O
introduced	O
to	O
make	O
C#	B-Application
less	O
verbose	O
,	O
and	O
thus	O
more	O
accessible	O
for	O
beginners	O
to	O
get	O
started.Types	O
are	O
declared	O
after	O
the	O
statements	O
,	O
and	O
will	O
be	O
automatically	O
available	O
from	O
the	O
statements	O
above	O
them	O
.	O
</s>
<s>
The	O
directive	O
loads	O
the	O
static	O
members	O
of	O
a	O
specified	O
type	O
into	O
the	O
current	O
scope	B-Language
,	O
making	O
them	O
accessible	O
directly	O
by	O
the	O
name	O
of	O
the	O
member	O
.	O
</s>
<s>
Some	O
of	O
the	O
existing	O
operators	O
can	O
be	O
overloaded	O
by	O
writing	O
an	O
overload	B-Language
method	B-Language
.	O
</s>
<s>
Array	B-Application
indexing	O
(	O
)	O
operator	O
is	O
not	O
overloadable	O
,	O
but	O
you	O
can	O
define	O
new	O
indexers	O
.	O
</s>
<s>
The	O
cast	O
operator	O
is	O
not	O
overloadable	O
but	O
you	O
can	O
write	O
a	O
conversion	O
operator	O
method	B-Language
which	O
lives	O
in	O
the	O
target	O
class	O
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Application
2.0	O
.	O
</s>
<s>
C#	B-Application
inherits	O
most	O
of	O
the	O
control	O
structures	B-General_Concept
of	O
C/C	O
++	O
and	O
also	O
adds	O
new	O
ones	O
like	O
the	O
foreach	O
statement	O
.	O
</s>
<s>
These	O
structures	B-General_Concept
control	O
the	O
flow	O
of	O
the	O
program	O
through	O
given	O
conditions	O
.	O
</s>
<s>
The	O
foreach	O
statement	O
is	O
derived	O
from	O
the	O
for	O
statement	O
and	O
makes	O
use	O
of	O
a	O
certain	O
pattern	O
described	O
in	O
C#'s	O
language	O
specification	O
in	O
order	O
to	O
obtain	O
and	O
use	O
an	O
enumerator	O
of	O
elements	O
to	O
iterate	O
over	O
.	O
</s>
<s>
Runtime	O
exception	O
handling	O
method	B-Language
in	O
C#	B-Application
is	O
inherited	O
from	O
Java	B-Language
and	O
C++	O
.	O
</s>
<s>
If	O
no	O
catch	O
block	O
matches	O
the	O
type	O
of	O
the	O
thrown	O
exception	O
,	O
the	O
execution	O
of	O
the	O
outer	O
block	O
(	O
or	O
method	B-Language
)	O
containing	O
the	O
try	O
...	O
catch	O
statement	O
is	O
discontinued	O
,	O
and	O
the	O
exception	O
is	O
passed	O
up	O
and	O
outside	O
the	O
containing	O
block	O
or	O
method	B-Language
.	O
</s>
<s>
The	O
exception	O
is	O
propagated	O
upwards	O
through	O
the	O
call	B-General_Concept
stack	I-General_Concept
until	O
a	O
matching	O
catch	O
block	O
is	O
found	O
within	O
one	O
of	O
the	O
currently	O
active	O
methods	O
.	O
</s>
<s>
If	O
the	O
exception	O
propagates	O
all	O
the	O
way	O
up	O
to	O
the	O
top-most	O
method	B-Language
without	O
a	O
matching	O
catch	O
block	O
being	O
found	O
,	O
the	O
entire	O
program	O
is	O
terminated	O
and	O
a	O
textual	O
description	O
of	O
the	O
exception	O
is	O
written	O
to	O
the	O
standard	O
output	O
stream	O
.	O
</s>
<s>
C#	B-Application
is	O
a	O
statically	O
typed	O
language	O
like	O
C	O
and	O
C++	O
.	O
</s>
<s>
If	O
the	O
variable	O
gets	O
out	O
of	O
scope	B-Language
the	O
object	O
is	O
destroyed	O
with	O
it	O
.	O
</s>
<s>
Structures	B-General_Concept
are	O
more	O
commonly	O
known	O
as	O
structs	B-Application
.	O
</s>
<s>
Structs	B-Application
are	O
user-defined	O
value	O
types	O
that	O
are	O
declared	O
using	O
the	O
struct	B-Application
keyword	O
.	O
</s>
<s>
Some	O
important	O
syntactical	O
differences	O
between	O
a	O
class	O
and	O
a	O
struct	B-Application
are	O
presented	O
later	O
in	O
this	O
article	O
.	O
</s>
<s>
The	O
primitive	O
data	O
types	O
are	O
all	O
structs	B-Application
.	O
</s>
<s>
Note	O
:	O
(	O
)	O
is	O
not	O
a	O
struct	B-Application
and	O
is	O
not	O
a	O
primitive	O
type	O
.	O
</s>
<s>
Enumerated	B-Language
types	I-Language
(	O
declared	O
with	O
enum	B-Language
)	O
are	O
named	O
values	O
representing	O
integer	O
values	O
.	O
</s>
<s>
Enum	B-Language
variables	O
are	O
initialized	O
by	O
default	O
to	O
zero	O
.	O
</s>
<s>
They	O
can	O
be	O
assigned	O
or	O
initialized	O
to	O
the	O
named	O
values	O
defined	O
by	O
the	O
enumeration	B-Language
type	O
.	O
</s>
<s>
Enum	B-Language
type	O
variables	O
are	O
integer	O
values	O
.	O
</s>
<s>
Casts	O
are	O
also	O
required	O
for	O
converting	O
enum	B-Language
variables	O
to	O
and	O
from	O
integer	O
types	O
.	O
</s>
<s>
When	O
a	O
variable	O
of	O
an	O
object	O
goes	O
out	O
of	O
scope	B-Language
the	O
reference	O
is	O
broken	O
and	O
when	O
there	O
are	O
no	O
references	O
left	O
the	O
object	O
gets	O
marked	O
as	O
garbage	O
.	O
</s>
<s>
An	O
array	B-Application
type	O
is	O
a	O
reference	O
type	O
that	O
refers	O
to	O
a	O
space	O
containing	O
one	O
or	O
more	O
elements	O
of	O
a	O
certain	O
type	O
.	O
</s>
<s>
All	O
array	B-Application
types	O
derive	O
from	O
a	O
common	O
base	O
class	O
,	O
.	O
</s>
<s>
Each	O
element	O
is	O
referenced	O
by	O
its	O
index	O
just	O
like	O
in	O
C++	O
and	O
Java	B-Language
.	O
</s>
<s>
An	O
array	B-Application
in	O
C#	B-Application
is	O
what	O
would	O
be	O
called	O
a	O
dynamic	B-Data_Structure
array	I-Data_Structure
in	O
C++	O
.	O
</s>
<s>
Array	B-Application
initializers	O
provide	O
convenient	O
syntax	O
for	O
initialization	O
of	O
arrays	O
.	O
</s>
<s>
Essentially	O
all	O
types	O
in	O
the	O
.NET	B-Application
Framework	I-Application
are	O
classes	O
,	O
including	O
structs	B-Application
and	O
enums	B-Language
,	O
that	O
are	O
compiler	B-Language
generated	O
classes	O
.	O
</s>
<s>
Interfaces	O
are	O
data	B-General_Concept
structures	I-General_Concept
that	O
contain	O
member	O
definitions	O
with	O
no	O
actual	O
implementation	O
.	O
</s>
<s>
C#	B-Application
provides	O
type-safe	O
object-oriented	B-Language
function	O
pointers	O
in	O
the	O
form	O
of	O
delegates	O
.	O
</s>
<s>
Initializing	O
the	O
delegate	O
with	O
an	O
anonymous	B-General_Concept
method	I-General_Concept
.	O
</s>
<s>
Initializing	O
the	O
delegate	O
with	O
lambda	B-General_Concept
expression	I-General_Concept
.	O
</s>
<s>
More	O
exactly	O
they	O
bind	O
method	B-Language
pointers	O
to	O
one	O
identifier	O
.	O
</s>
<s>
The	O
form	O
used	O
in	O
C#	B-Application
and	O
the	O
rest	O
of	O
the	O
Common	O
Language	O
Infrastructure	O
is	O
based	O
on	O
that	O
in	O
the	O
classic	B-Language
Visual	I-Language
Basic	I-Language
.	O
</s>
<s>
An	O
event	O
requires	O
an	O
accompanied	O
event	O
handler	O
that	O
is	O
made	O
from	O
a	O
special	O
delegate	O
that	O
in	O
a	O
platform	O
specific	O
library	O
like	O
in	O
Windows	B-Device
Presentation	I-Device
Foundation	I-Device
and	O
Windows	B-Application
Forms	I-Application
usually	O
takes	O
two	O
parameters	O
:	O
sender	O
and	O
the	O
event	O
arguments	O
.	O
</s>
<s>
A	O
listener	O
method	B-Language
may	O
be	O
implemented	O
outside	O
to	O
be	O
triggered	O
when	O
the	O
event	O
is	O
fired	O
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Application
2.0	O
.	O
</s>
<s>
Nullable	O
types	O
were	O
introduced	O
in	O
C#	B-Application
2.0	O
firstly	O
to	O
enable	O
value	O
types	O
to	O
be	O
null	O
(	O
useful	O
when	O
working	O
with	O
a	O
database	O
)	O
.	O
</s>
<s>
In	O
reality	O
this	O
is	O
the	O
same	O
as	O
using	O
the	O
struct	B-Application
.	O
</s>
<s>
C#	B-Application
has	O
and	O
allows	O
pointers	O
to	O
selected	O
types	O
(	O
some	O
primitives	O
,	O
enums	B-Language
,	O
strings	O
,	O
pointers	O
,	O
and	O
even	O
arrays	O
and	O
structs	B-Application
if	O
they	O
contain	O
only	O
types	O
that	O
can	O
be	O
pointed	O
)	O
in	O
unsafe	O
context	O
:	O
methods	O
and	O
codeblock	O
marked	O
unsafe	O
.	O
</s>
<s>
Structs	B-Application
are	O
required	O
only	O
to	O
be	O
pure	O
structs	B-Application
with	O
no	O
members	O
of	O
a	O
managed	O
reference	O
type	O
,	O
e.g.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Language
4.0	I-Language
and	O
.NET	B-Application
Framework	I-Application
4.0	O
.	O
</s>
<s>
Type	O
dynamic	O
is	O
a	O
feature	O
that	O
enables	O
dynamic	O
runtime	O
lookup	O
to	O
C#	B-Application
in	O
a	O
static	O
manner	O
.	O
</s>
<s>
Dynamic	O
denotes	O
a	O
variable	O
with	O
an	O
object	O
with	O
a	O
type	O
that	O
is	O
resolved	O
at	O
runtime	O
,	O
as	O
opposed	O
to	O
compile-time	O
,	O
as	O
normally	O
is	O
done	O
.	O
</s>
<s>
This	O
feature	O
takes	O
advantage	O
of	O
the	O
Dynamic	B-Application
Language	I-Application
Runtime	I-Application
(	O
DLR	O
)	O
and	O
has	O
been	O
designed	O
specifically	O
with	O
the	O
goal	O
of	O
interoperation	O
with	O
dynamically	O
typed	O
languages	O
like	O
IronPython	B-Application
and	O
IronRuby	B-Language
(	O
Implementations	O
of	O
Python	B-Language
and	O
Ruby	B-Language
for	O
.NET	B-Application
)	O
.	O
</s>
<s>
Dynamic-support	O
also	O
eases	O
interoperation	O
with	O
COM	B-Application
objects	I-Application
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Language
3.0	I-Language
.	O
</s>
<s>
Anonymous	O
types	O
are	O
nameless	O
classes	O
that	O
are	O
generated	O
by	O
the	O
compiler	B-Language
.	O
</s>
<s>
When	O
instantiating	O
another	O
anonymous	O
type	O
declaration	O
with	O
the	O
same	O
signature	O
the	O
type	O
is	O
automatically	O
inferred	O
by	O
the	O
compiler	B-Language
.	O
</s>
<s>
Boxing	O
in	O
C#	B-Application
is	O
implicit	O
.	O
</s>
<s>
Unboxing	O
in	O
C#	B-Application
requires	O
an	O
explicit	O
type	O
cast	O
.	O
</s>
<s>
C#	B-Application
has	O
direct	O
support	O
for	O
object-oriented	B-Language
programming	I-Language
.	O
</s>
<s>
An	O
object	O
is	O
created	O
with	O
the	O
type	O
as	O
a	O
template	B-Application
and	O
is	O
called	O
an	O
instance	O
of	O
that	O
particular	O
type	O
.	O
</s>
<s>
In	O
C#	B-Application
,	O
objects	O
are	O
either	O
references	O
or	O
values	O
.	O
</s>
<s>
All	O
types	O
,	O
even	O
value	O
types	O
in	O
their	O
boxed	O
form	O
,	O
implicitly	O
inherit	B-Language
from	O
the	O
class	O
,	O
the	O
ultimate	O
base	O
class	O
of	O
all	O
objects	O
.	O
</s>
<s>
Classes	O
inherit	B-Language
either	O
directly	O
or	O
indirectly	O
through	O
another	O
base	O
class	O
.	O
</s>
<s>
Classes	O
are	O
fundamentals	O
of	O
an	O
object-oriented	B-Language
language	I-Language
such	O
as	O
C#	B-Application
.	O
</s>
<s>
They	O
serve	O
as	O
a	O
template	B-Application
for	O
objects	O
.	O
</s>
<s>
Although	O
classes	O
and	O
structures	B-General_Concept
are	O
similar	O
in	O
both	O
the	O
way	O
they	O
are	O
declared	O
and	O
how	O
they	O
are	O
used	O
,	O
there	O
are	O
some	O
significant	O
differences	O
.	O
</s>
<s>
Classes	O
are	O
reference	O
types	O
and	O
structs	B-Application
are	O
value	O
types	O
.	O
</s>
<s>
Structures	B-General_Concept
require	O
some	O
more	O
work	O
than	O
classes	O
.	O
</s>
<s>
For	O
example	O
,	O
you	O
need	O
to	O
explicitly	O
create	O
a	O
default	O
constructor	O
which	O
takes	O
no	O
arguments	O
to	O
initialize	O
the	O
struct	B-Application
and	O
its	O
members	O
.	O
</s>
<s>
The	O
compiler	B-Language
will	O
create	O
a	O
default	O
one	O
for	O
classes	O
.	O
</s>
<s>
All	O
fields	O
and	O
properties	B-Language
of	O
a	O
struct	B-Application
must	O
have	O
been	O
initialized	O
before	O
an	O
instance	O
is	O
created	O
.	O
</s>
<s>
Structs	B-Application
do	O
not	O
have	O
finalizers	O
and	O
cannot	O
inherit	B-Language
from	O
another	O
class	O
like	O
classes	O
do	O
.	O
</s>
<s>
However	O
,	O
they	O
inherit	B-Language
from	O
,	O
that	O
inherits	O
from	O
.	O
</s>
<s>
Structs	B-Application
are	O
more	O
suitable	O
for	O
smaller	O
constructs	O
of	O
data	O
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Application
2.0	O
.	O
</s>
<s>
For	O
structs	B-Application
it	O
is	O
optional	O
to	O
explicitly	O
call	O
a	O
constructor	O
because	O
the	O
default	O
one	O
is	O
called	O
automatically	O
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Language
3.0	I-Language
.	O
</s>
<s>
Provides	O
a	O
more	O
convenient	O
way	O
of	O
initializing	O
public	O
fields	O
and	O
properties	B-Language
of	O
an	O
object	O
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Language
3.0	I-Language
.	O
</s>
<s>
Collection	O
initializers	O
give	O
an	O
array-like	O
syntax	O
for	O
initializing	O
collections	O
.	O
</s>
<s>
The	O
compiler	B-Language
will	O
simply	O
generate	O
calls	O
to	O
the	O
Add-method	O
.	O
</s>
<s>
In	O
unsafe	O
code	O
,	O
members	O
of	O
a	O
value	O
(	O
struct	B-Application
type	O
)	O
referenced	O
by	O
a	O
pointer	O
are	O
accessed	O
with	O
the	O
operator	O
just	O
like	O
in	O
C	O
and	O
C++	O
.	O
</s>
<s>
extern	O
-	O
Specifies	O
that	O
a	O
method	B-Language
signature	O
without	O
a	O
body	O
uses	O
a	O
DLL-import	O
.	O
</s>
<s>
override	O
-	O
Specifies	O
that	O
a	O
method	B-Language
or	O
property	O
declaration	O
is	O
an	O
override	O
of	O
a	O
virtual	O
member	O
or	O
an	O
implementation	O
of	O
a	O
member	O
of	O
an	O
abstract	O
class	O
.	O
</s>
<s>
virtual	O
-	O
Specifies	O
that	O
a	O
method	B-Language
or	O
property	O
declaration	O
can	O
be	O
overridden	O
by	O
a	O
derived	O
class	O
.	O
</s>
<s>
volatile	O
-	O
Specifies	O
a	O
field	O
which	O
may	O
be	O
modified	O
by	O
an	O
external	O
process	O
and	O
prevents	O
an	O
optimizing	O
compiler	B-Language
from	O
modifying	O
the	O
use	O
of	O
the	O
field	O
.	O
</s>
<s>
The	O
access	O
modifiers	O
,	O
or	O
inheritance	B-Language
modifiers	O
,	O
set	O
the	O
accessibility	O
of	O
classes	O
,	O
methods	O
,	O
and	O
other	O
members	O
.	O
</s>
<s>
Classes	O
and	O
structs	B-Application
are	O
implicitly	O
and	O
members	O
are	O
implicitly	O
if	O
they	O
do	O
not	O
have	O
an	O
access	O
modifier	O
.	O
</s>
<s>
A	O
constructor	O
is	O
a	O
special	O
method	B-Language
that	O
is	O
called	O
automatically	O
when	O
an	O
object	O
is	O
created	O
.	O
</s>
<s>
They	O
may	O
take	O
parameters	O
like	O
any	O
other	O
method	B-Language
.	O
</s>
<s>
The	O
destructor	B-Language
is	O
called	O
when	O
the	O
object	O
is	O
being	O
collected	O
by	O
the	O
garbage	O
collector	O
to	O
perform	O
some	O
manual	O
clean-up	O
.	O
</s>
<s>
There	O
is	O
a	O
default	O
destructor	B-Language
method	B-Language
called	O
that	O
can	O
be	O
overridden	O
by	O
declaring	O
your	O
own	O
.	O
</s>
<s>
There	O
cannot	O
be	O
more	O
than	O
one	O
destructor	B-Language
.	O
</s>
<s>
The	O
main	O
difference	O
is	O
that	O
functions	O
,	O
just	O
like	O
in	O
Java	B-Language
,	O
have	O
to	O
reside	O
inside	O
of	O
a	O
class	O
.	O
</s>
<s>
A	O
function	O
is	O
therefore	O
called	O
a	O
method	B-Language
.	O
</s>
<s>
A	O
method	B-Language
has	O
a	O
return	O
value	O
,	O
a	O
name	O
and	O
usually	O
some	O
parameters	O
initialized	O
when	O
it	O
is	O
called	O
with	O
some	O
arguments	O
.	O
</s>
<s>
A	O
method	B-Language
is	O
called	O
using	O
notation	O
on	O
a	O
specific	O
variable	O
,	O
or	O
as	O
in	O
the	O
case	O
of	O
static	B-Language
methods	I-Language
,	O
the	O
name	O
of	O
a	O
type	O
.	O
</s>
<s>
One	O
can	O
explicitly	O
make	O
arguments	O
be	O
passed	O
by	O
reference	O
when	O
calling	O
a	O
method	B-Language
with	O
parameters	O
preceded	O
by	O
keywords	O
ref	O
or	O
out	O
.	O
</s>
<s>
These	O
managed	O
pointers	O
come	O
in	O
handy	O
when	O
passing	O
variables	O
that	O
you	O
want	O
to	O
be	O
modified	O
inside	O
the	O
method	B-Language
by	O
reference	O
.	O
</s>
<s>
The	O
main	O
difference	O
between	O
the	O
two	O
is	O
that	O
an	O
out	O
parameter	O
must	O
have	O
been	O
assigned	O
within	O
the	O
method	B-Language
by	O
the	O
time	O
the	O
method	B-Language
returns	O
,	O
while	O
ref	O
need	O
not	O
assign	O
a	O
value	O
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Language
4.0	I-Language
.	O
</s>
<s>
C#	B-Language
4.0	I-Language
introduces	O
optional	O
parameters	O
with	O
default	O
values	O
as	O
seen	O
in	O
C++	O
.	O
</s>
<s>
In	O
addition	O
,	O
to	O
complement	O
optional	O
parameters	O
,	O
it	O
is	O
possible	O
to	O
explicitly	O
specify	O
parameter	O
names	O
in	O
method	B-Language
calls	I-Language
,	O
allowing	O
to	O
selectively	O
pass	O
any	O
given	O
subset	O
of	O
optional	O
parameters	O
for	O
a	O
method	B-Language
.	O
</s>
<s>
Optional	O
parameters	O
make	O
interoperating	O
with	O
COM	B-Application
easier	O
.	O
</s>
<s>
Previously	O
,	O
C#	B-Application
had	O
to	O
pass	O
in	O
every	O
parameter	O
in	O
the	O
method	B-Language
of	O
the	O
COM	B-Application
component	O
,	O
even	O
those	O
that	O
are	O
optional	O
.	O
</s>
<s>
A	O
feature	O
of	O
C#	B-Application
is	O
the	O
ability	O
to	O
call	O
native	O
code	O
.	O
</s>
<s>
A	O
method	B-Language
signature	O
is	O
simply	O
declared	O
without	O
a	O
body	O
and	O
is	O
marked	O
as	O
extern	O
.	O
</s>
<s>
Fields	O
,	O
or	O
class	B-Application
variables	I-Application
,	O
can	O
be	O
declared	O
inside	O
the	O
class	O
body	O
to	O
store	O
data	O
.	O
</s>
<s>
Fields	O
can	O
be	O
initialized	O
directly	O
when	O
declared	O
(	O
unless	O
declared	O
in	O
struct	B-Application
)	O
.	O
</s>
<s>
Properties	B-Language
bring	O
field-like	O
syntax	O
and	O
combine	O
them	O
with	O
the	O
power	O
of	O
methods	O
.	O
</s>
<s>
Modifiers	O
for	O
properties	B-Language
:	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Language
3.0	I-Language
.	O
</s>
<s>
A	O
feature	O
of	O
C#	B-Language
3.0	I-Language
is	O
auto-implemented	O
properties	B-Language
.	O
</s>
<s>
You	O
define	O
accessors	O
without	O
bodies	O
and	O
the	O
compiler	B-Language
will	O
generate	O
a	O
backing	O
field	O
and	O
the	O
necessary	O
code	O
for	O
the	O
accessors	O
.	O
</s>
<s>
Indexers	O
add	O
array-like	O
indexing	O
capabilities	O
to	O
objects	O
.	O
</s>
<s>
They	O
are	O
implemented	O
in	O
a	O
way	O
similar	O
to	O
properties	B-Language
.	O
</s>
<s>
Classes	O
in	O
C#	B-Application
may	O
only	O
inherit	B-Language
from	O
one	O
class	O
.	O
</s>
<s>
When	O
overloading	O
a	O
non-virtual	O
method	B-Language
with	O
another	O
signature	O
,	O
the	O
keyword	O
new	O
may	O
be	O
used	O
.	O
</s>
<s>
The	O
used	O
method	B-Language
will	O
be	O
chosen	O
by	O
the	O
type	O
of	O
the	O
variable	O
instead	O
of	O
the	O
actual	O
type	O
of	O
the	O
object	O
.	O
</s>
<s>
Abstract	O
classes	O
are	O
classes	O
that	O
only	O
serve	O
as	O
templates	B-Application
and	O
you	O
can	O
not	O
initialize	O
an	O
object	O
of	O
that	O
type	O
.	O
</s>
<s>
Interfaces	O
are	O
data	B-General_Concept
structures	I-General_Concept
that	O
contain	O
member	O
definitions	O
and	O
not	O
actual	O
implementation	O
.	O
</s>
<s>
You	O
can	O
declare	O
definitions	O
for	O
methods	O
,	O
properties	B-Language
,	O
and	O
indexers	O
.	O
</s>
<s>
Note	O
:	O
The	O
properties	B-Language
in	O
the	O
class	O
that	O
extends	O
are	O
auto-implemented	O
by	O
the	O
compiler	B-Language
and	O
a	O
backing	O
field	O
is	O
automatically	O
added	O
(	O
see	O
#Automatic	O
properties	B-Language
)	O
.	O
</s>
<s>
An	O
abstract	O
class	O
may	O
have	O
member	O
variables	O
as	O
well	O
as	O
non-abstract	O
methods	O
or	O
properties	B-Language
.	O
</s>
<s>
A	O
class	O
or	O
abstract	O
class	O
can	O
only	O
inherit	B-Language
from	O
one	O
class	O
or	O
abstract	O
class	O
.	O
</s>
<s>
An	O
abstract	O
class	O
may	O
have	O
non-public	O
methods	O
and	O
properties	B-Language
(	O
also	O
abstract	O
ones	O
)	O
.	O
</s>
<s>
An	O
abstract	O
class	O
may	O
have	O
constants	O
,	O
static	B-Language
methods	I-Language
and	O
static	O
members	O
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Application
2.0	O
and	O
.NET	B-Application
Framework	I-Application
2.0	O
.	O
</s>
<s>
Generics	B-Language
(	O
or	O
parameterized	B-Language
types	I-Language
,	O
parametric	O
polymorphism	O
)	O
use	O
type	O
parameters	O
,	O
which	O
make	O
it	O
possible	O
to	O
design	O
classes	O
and	O
methods	O
that	O
do	O
not	O
specify	O
the	O
type	O
used	O
until	O
the	O
class	O
or	O
method	B-Language
is	O
instantiated	O
.	O
</s>
<s>
The	O
main	O
advantage	O
is	O
that	O
one	O
can	O
use	O
generic	B-Language
type	I-Language
parameters	O
to	O
create	O
classes	O
and	O
methods	O
that	O
can	O
be	O
used	O
without	O
incurring	O
the	O
cost	O
of	O
runtime	O
casts	O
or	O
boxing	O
operations	O
,	O
as	O
shown	O
here	O
:	O
</s>
<s>
When	O
compared	O
with	O
C++	B-Application
templates	I-Application
,	O
C#	B-Application
generics	B-Language
can	O
provide	O
enhanced	O
safety	O
,	O
but	O
also	O
have	O
somewhat	O
limited	O
capabilities	O
.	O
</s>
<s>
For	O
example	O
,	O
it	O
is	O
not	O
possible	O
to	O
call	O
arithmetic	O
operators	O
on	O
a	O
C#	B-Application
generic	B-Language
type	I-Language
.	O
</s>
<s>
Unlike	O
C++	B-Application
templates	I-Application
,	O
.NET	B-Application
parameterized	B-Language
types	I-Language
are	O
instantiated	O
at	O
runtime	O
rather	O
than	O
by	O
the	O
compiler	B-Language
;	O
hence	O
they	O
can	O
be	O
cross-language	O
whereas	O
C++	B-Application
templates	I-Application
cannot	O
.	O
</s>
<s>
They	O
support	O
some	O
features	O
not	O
supported	O
directly	O
by	O
C++	B-Application
templates	I-Application
such	O
as	O
type	O
constraints	O
on	O
generic	B-Language
parameters	O
by	O
use	O
of	O
interfaces	O
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
C#	B-Application
does	O
not	O
support	O
non-type	O
generic	B-Language
parameters	O
.	O
</s>
<s>
Unlike	O
generics	B-Language
in	O
Java	B-Language
,	O
.NET	B-Application
generics	B-Language
use	O
reification	O
to	O
make	O
parameterized	B-Language
types	I-Language
first-class	O
objects	O
in	O
the	O
Common	O
Language	O
Infrastructure	O
(	O
CLI	O
)	O
Virtual	O
Machine	O
,	O
which	O
allows	O
for	O
optimizations	O
and	O
preservation	O
of	O
the	O
type	O
information	O
.	O
</s>
<s>
Classes	O
and	O
structs	B-Application
can	O
be	O
generic	B-Language
.	O
</s>
<s>
Type-parameters	O
are	O
names	O
used	O
in	O
place	O
of	O
concrete	O
types	O
when	O
defining	O
a	O
new	O
generic	B-Language
.	O
</s>
<s>
When	O
instantiating	O
(	O
or	O
calling	O
)	O
a	O
generic	B-Language
,	O
you	O
can	O
then	O
substitute	O
a	O
concrete	O
type	O
for	O
the	O
type-parameter	O
you	O
gave	O
in	O
its	O
declaration	O
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Language
4.0	I-Language
and	O
.NET	B-Application
Framework	I-Application
4.0	O
.	O
</s>
<s>
Generic	B-Language
interfaces	O
and	O
delegates	O
can	O
have	O
their	O
type	O
parameters	O
marked	O
as	O
covariant	O
or	O
contravariant	O
,	O
using	O
keywords	O
out	O
and	O
in	O
,	O
respectively	O
.	O
</s>
<s>
These	O
declarations	O
are	O
then	O
respected	O
for	O
type	O
conversions	O
,	O
both	O
implicit	O
and	O
explicit	O
,	O
and	O
both	O
compile-time	O
and	O
run-time	O
.	O
</s>
<s>
Enumerators	O
are	O
typically	O
obtained	O
by	O
calling	O
the	O
method	B-Language
of	O
an	O
object	O
implementing	O
the	O
interface	O
.	O
</s>
<s>
However	O
,	O
the	O
foreach	O
statement	O
in	O
C#	B-Application
can	O
operate	O
on	O
any	O
object	O
providing	O
such	O
a	O
method	B-Language
,	O
even	O
if	O
it	O
does	O
n't	O
implement	O
.	O
</s>
<s>
This	O
interface	O
was	O
expanded	O
into	O
generic	B-Language
version	O
in	O
.NET	B-Application
2.0	O
.	O
</s>
<s>
The	O
following	O
shows	O
a	O
simple	O
use	O
of	O
iterators	O
in	O
C#	B-Application
2.0	O
:	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Application
2.0	O
.	O
</s>
<s>
The	O
.NET	B-Application
2.0	O
Framework	O
allowed	O
C#	B-Application
to	O
introduce	O
an	O
iterator	O
that	O
provides	O
generator	O
functionality	O
,	O
using	O
a	O
construct	O
similar	O
to	O
yield	O
in	O
Python	B-Language
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Language
3.0	I-Language
and	O
.NET	B-Application
Framework	I-Application
3.0	O
.	O
</s>
<s>
LINQ	O
,	O
short	O
for	O
Language	O
Integrated	O
Queries	O
,	O
is	O
a	O
.NET	B-Application
Framework	I-Application
feature	O
which	O
simplifies	O
the	O
handling	O
of	O
data	O
.	O
</s>
<s>
The	O
LINQ	O
query	O
syntax	O
was	O
introduced	O
in	O
C#	B-Language
3.0	I-Language
and	O
lets	O
you	O
write	O
SQL-like	O
queries	O
in	O
C#	B-Application
.	O
</s>
<s>
The	O
statements	O
are	O
compiled	B-Language
into	O
method	B-Language
calls	I-Language
,	O
whereby	O
almost	O
only	O
the	O
names	O
of	O
the	O
methods	O
are	O
specified	O
.	O
</s>
<s>
Which	O
methods	O
are	O
ultimately	O
used	O
is	O
determined	O
by	O
normal	O
overload	B-Language
resolution	I-Language
.	O
</s>
<s>
Thus	O
,	O
the	O
end	O
result	O
of	O
the	O
translation	O
is	O
affected	O
by	O
what	O
symbols	O
are	O
in	O
scope	B-Language
.	O
</s>
<s>
What	O
differs	O
from	O
SQL	B-Language
is	O
that	O
the	O
from-statement	O
comes	O
first	O
and	O
not	O
last	O
as	O
in	O
SQL	B-Language
.	O
</s>
<s>
This	O
is	O
because	O
it	O
seems	O
more	O
natural	O
writing	O
like	O
this	O
in	O
C#	B-Application
and	O
supports	O
"	O
Intellisense	O
"	O
(	O
Code	O
completion	O
in	O
the	O
editor	O
)	O
.	O
</s>
<s>
Anonymous	B-General_Concept
methods	I-General_Concept
,	O
or	O
in	O
their	O
present	O
form	O
more	O
commonly	O
referred	O
to	O
as	O
"	O
lambda	B-General_Concept
expressions	I-General_Concept
"	O
,	O
is	O
a	O
feature	O
which	O
allows	O
you	O
to	O
write	O
inline	O
closure-like	O
functions	O
in	O
your	O
code	O
.	O
</s>
<s>
There	O
are	O
various	O
ways	O
to	O
create	O
anonymous	B-General_Concept
methods	I-General_Concept
.	O
</s>
<s>
Prior	O
to	O
C#	B-Language
3.0	I-Language
there	O
was	O
limited	O
support	O
by	O
using	O
delegates	O
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Application
2.0	O
.	O
</s>
<s>
Anonymous	O
delegates	O
are	O
functions	O
pointers	O
that	O
hold	O
anonymous	B-General_Concept
methods	I-General_Concept
.	O
</s>
<s>
Instead	O
of	O
declaring	O
a	O
separate	O
method	B-Language
in	O
code	O
the	O
programmer	O
can	O
use	O
the	O
syntax	O
to	O
write	O
the	O
code	O
inline	O
and	O
the	O
compiler	B-Language
will	O
then	O
generate	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
for	O
it	O
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Language
3.0	I-Language
.	O
</s>
<s>
Lambda	B-General_Concept
expressions	I-General_Concept
provide	O
a	O
simple	O
syntax	O
for	O
inline	O
functions	O
that	O
are	O
similar	O
to	O
closures	B-Language
.	O
</s>
<s>
Multi-statement	O
lambdas	B-General_Concept
have	O
bodies	O
enclosed	O
by	O
braces	O
and	O
inside	O
of	O
them	O
code	O
can	O
be	O
written	O
like	O
in	O
standard	O
methods	O
.	O
</s>
<s>
Lambda	B-General_Concept
expressions	I-General_Concept
can	O
be	O
passed	O
as	O
arguments	O
directly	O
in	O
method	B-Language
calls	I-Language
similar	O
to	O
anonymous	O
delegates	O
but	O
with	O
a	O
more	O
aesthetic	O
syntax	O
.	O
</s>
<s>
Lambda	B-General_Concept
expressions	I-General_Concept
are	O
essentially	O
compiler-generated	O
methods	O
that	O
are	O
passed	O
via	O
delegates	O
.	O
</s>
<s>
These	O
methods	O
are	O
reserved	O
for	O
the	O
compiler	B-Language
only	O
and	O
can	O
not	O
be	O
used	O
in	O
any	O
other	O
context	O
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Language
3.0	I-Language
.	O
</s>
<s>
In	O
practice	O
,	O
an	O
extension	O
method	B-Language
is	O
a	O
static	O
method	B-Language
that	O
is	O
callable	O
as	O
if	O
it	O
were	O
an	O
instance	B-Language
method	I-Language
;	O
the	O
receiver	O
of	O
the	O
call	O
is	O
bound	O
to	O
the	O
first	O
parameter	O
of	O
the	O
method	B-Language
,	O
decorated	O
with	O
keyword	O
this	O
:	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Application
7.0	O
.	O
</s>
<s>
Local	O
functions	O
can	O
be	O
defined	O
in	O
the	O
body	O
of	O
another	O
method	B-Language
,	O
constructor	O
or	O
property	O
’s	O
getter	O
and	O
setter	O
.	O
</s>
<s>
Such	O
functions	O
have	O
access	O
to	O
all	O
variables	O
in	O
the	O
enclosing	O
scope	B-Language
,	O
including	O
parent	O
method	B-Language
local	O
variables	O
.	O
</s>
<s>
They	O
are	O
in	O
scope	B-Language
for	O
the	O
entire	O
method	B-Language
,	O
regardless	O
of	O
whether	O
they	O
’re	O
invoked	O
before	O
or	O
after	O
their	O
declaration	O
.	O
</s>
<s>
Also	O
they	O
do	O
not	O
support	O
function	B-Language
overloading	I-Language
.	O
</s>
<s>
It	O
means	O
there	O
cannot	O
be	O
two	O
local	O
functions	O
in	O
the	O
same	O
method	B-Language
with	O
the	O
same	O
name	O
even	O
if	O
the	O
signatures	O
do	O
n’t	O
overlap	O
.	O
</s>
<s>
After	O
a	O
compilation	B-Language
,	O
a	O
local	O
function	O
is	O
transformed	O
into	O
a	O
private	O
static	O
method	B-Language
,	O
but	O
when	O
defined	O
it	O
cannot	O
be	O
marked	O
static	O
.	O
</s>
<s>
In	O
code	O
example	O
below	O
,	O
the	O
Sum	O
method	B-Language
is	O
a	O
local	O
function	O
inside	O
Main	O
method	B-Language
.	O
</s>
<s>
So	O
it	O
can	O
be	O
used	O
only	O
inside	O
its	O
parent	O
method	B-Language
Main	O
:	O
</s>
<s>
C#	B-Application
implements	O
closure	B-Language
blocks	O
by	O
means	O
of	O
the	O
.	O
</s>
<s>
The	O
using	O
statement	O
accepts	O
an	O
expression	O
which	O
results	O
in	O
an	O
object	O
implementing	O
,	O
and	O
the	O
compiler	B-Language
generates	O
code	O
that	O
guarantees	O
the	O
object	O
's	O
disposal	O
when	O
the	O
scope	B-Language
of	O
the	O
using-statement	O
is	O
exited	O
.	O
</s>
<s>
C#	B-Application
provides	O
the	O
,	O
which	O
is	O
yet	O
another	O
example	O
of	O
beneficial	O
syntactic	O
sugar	O
.	O
</s>
<s>
It	O
works	O
by	O
marking	O
a	O
block	O
of	O
code	O
as	O
a	O
critical	B-Operating_System
section	I-Operating_System
by	O
mutual	O
exclusion	O
of	O
access	O
to	O
a	O
provided	O
object	O
.	O
</s>
<s>
Like	O
the	O
using	O
statement	O
,	O
it	O
works	O
by	O
the	O
compiler	B-Language
generating	O
a	O
block	O
in	O
its	O
place	O
.	O
</s>
<s>
Attributes	O
are	O
entities	O
of	O
data	O
that	O
are	O
stored	O
as	O
metadata	O
in	O
the	O
compiled	B-Language
assembly	O
.	O
</s>
<s>
An	O
attribute	O
can	O
be	O
added	O
to	O
types	O
and	O
members	O
like	O
properties	B-Language
and	O
methods	O
.	O
</s>
<s>
The	O
.NET	B-Application
Framework	I-Application
comes	O
with	O
predefined	O
attributes	O
that	O
can	O
be	O
used	O
.	O
</s>
<s>
It	O
does	O
only	O
mark	O
that	O
it	O
is	O
a	O
compiler-generated	O
element	O
.	O
</s>
<s>
C#	B-Application
features	O
"	O
preprocessor	O
directives	O
"	O
(	O
though	O
it	O
does	O
not	O
have	O
an	O
actual	O
preprocessor	O
)	O
based	O
on	O
the	O
C	B-Language
preprocessor	I-Language
that	O
allow	O
programmers	O
to	O
define	O
symbols	O
,	O
but	O
not	O
macros	O
.	O
</s>
<s>
Directives	O
such	O
as	O
give	O
hints	O
to	O
editors	O
for	O
code	B-Application
folding	I-Application
.	O
</s>
<s>
C#	B-Application
utilizes	O
a	O
double	O
slash	O
(	O
)	O
to	O
indicate	O
the	O
rest	O
of	O
the	O
line	O
is	O
a	O
comment	O
.	O
</s>
<s>
Single-line	O
comments	O
beginning	O
with	O
three	O
slashes	O
are	O
used	O
for	O
XML	B-Protocol
documentation	O
.	O
</s>
<s>
This	O
,	O
however	O
,	O
is	O
a	O
convention	O
used	O
by	O
Visual	B-Application
Studio	I-Application
and	O
is	O
not	O
part	O
of	O
the	O
language	O
definition	O
:	O
</s>
<s>
C#'s	O
documentation	O
system	O
is	O
similar	O
to	O
Java	B-Language
's	O
Javadoc	B-Language
,	O
but	O
based	O
on	O
XML	B-Protocol
.	O
</s>
<s>
Two	O
methods	O
of	O
documentation	O
are	O
currently	O
supported	O
by	O
the	O
C#	B-Application
compiler	B-Language
.	O
</s>
<s>
Single-line	O
documentation	O
comments	O
,	O
such	O
as	O
those	O
commonly	O
found	O
in	O
Visual	B-Application
Studio	I-Application
generated	O
code	O
,	O
are	O
indicated	O
on	O
a	O
line	O
beginning	O
with	O
.	O
</s>
<s>
Multi-line	O
documentation	O
comments	O
,	O
while	O
defined	O
in	O
the	O
version	O
1.0	O
language	O
specification	O
,	O
were	O
not	O
supported	O
until	O
the	O
.NET	B-Application
1.1	O
release	O
.	O
</s>
<s>
There	O
are	O
some	O
stringent	O
criteria	O
regarding	O
white	O
space	O
and	O
XML	B-Protocol
documentation	O
when	O
using	O
the	O
forward	O
slash/asterisk/asterisk	O
(	O
)	O
technique	O
.	O
</s>
<s>
produces	O
a	O
different	O
XML	B-Protocol
comment	O
than	O
this	O
code	O
block	O
:	O
</s>
<s>
Syntax	O
for	O
documentation	O
comments	O
and	O
their	O
XML	B-Protocol
markup	O
is	O
defined	O
in	O
a	O
non-normative	O
annex	O
of	O
the	O
ECMA	O
C#	B-Application
standard	O
.	O
</s>
<s>
The	O
same	O
standard	O
also	O
defines	O
rules	O
for	O
processing	O
of	O
such	O
comments	O
,	O
and	O
their	O
transformation	O
to	O
a	O
plain	O
XML	B-Protocol
document	I-Protocol
with	O
precise	O
rules	O
for	O
mapping	O
of	O
Common	O
Language	O
Infrastructure	O
(	O
CLI	O
)	O
identifiers	O
to	O
their	O
related	O
documentation	O
elements	O
.	O
</s>
<s>
This	O
allows	O
any	O
C#	B-Application
integrated	B-Application
development	I-Application
environment	I-Application
(	O
IDE	O
)	O
or	O
other	O
development	O
tool	O
to	O
find	O
documentation	O
for	O
any	O
symbol	O
in	O
the	O
code	O
in	O
a	O
certain	O
well-defined	O
way	O
.	O
</s>
<s>
This	O
is	O
a	O
feature	O
of	O
C#	B-Application
5.0	I-Application
and	O
.NET	B-Application
Framework	I-Application
4.0	O
.	O
</s>
<s>
As	O
of	O
.NET	B-Application
Framework	I-Application
4	O
there	O
is	O
a	O
task	O
library	O
that	O
makes	O
it	O
easier	O
to	O
write	O
parallel	O
and	O
multi-threaded	O
applications	O
through	O
tasks	O
.	O
</s>
<s>
C#	B-Application
5.0	I-Application
has	O
native	O
language	O
support	O
for	O
asynchrony	O
.	O
</s>
<s>
Spec#	O
is	O
a	O
dialect	O
of	O
C#	B-Application
that	O
is	O
developed	O
in	O
parallel	O
with	O
the	O
standard	O
implementation	O
from	O
Microsoft	O
.	O
</s>
<s>
It	O
extends	O
C#	B-Application
with	O
specification	O
language	O
features	O
and	O
is	O
a	O
possible	O
future	O
feature	O
to	O
the	O
C#	B-Application
language	O
.	O
</s>
<s>
It	O
also	O
adds	O
syntax	O
for	O
the	O
code	O
contracts	O
API	O
that	O
was	O
introduced	O
in	O
.NET	B-Application
Framework	I-Application
4.0	O
.	O
</s>
<s>
This	O
sample	O
shows	O
two	O
of	O
the	O
basic	O
structures	B-General_Concept
that	O
are	O
used	O
when	O
adding	O
contracts	O
to	O
your	O
code	O
.	O
</s>
<s>
Spec#	O
extends	O
C#	B-Application
with	O
non-nullable	O
types	O
that	O
simply	O
checks	O
so	O
the	O
variables	O
of	O
nullable	O
types	O
that	O
has	O
been	O
set	O
as	O
non-nullable	O
are	O
not	O
null	O
.	O
</s>
<s>
Preconditions	O
are	O
checked	O
before	O
a	O
method	B-Language
is	O
executed	O
.	O
</s>
<s>
Postconditions	O
are	O
conditions	O
that	O
are	O
ensured	O
to	O
be	O
correct	O
when	O
a	O
method	B-Language
has	O
been	O
executed	O
.	O
</s>
<s>
Spec#	O
adds	O
checked	O
exceptions	O
like	O
those	O
in	O
Java	B-Language
.	O
</s>
<s>
Checked	O
exceptions	O
are	O
problematic	O
,	O
because	O
when	O
a	O
lower-level	O
function	O
adds	O
a	O
new	O
exception	O
type	O
,	O
the	O
whole	O
chain	O
of	O
methods	O
using	O
this	O
method	B-Language
at	O
some	O
nested	O
lower	O
level	O
must	O
also	O
change	O
its	O
contract	O
.	O
</s>
