<s>
The	O
programming	O
language	O
C#	B-Application
version	O
3.0	O
was	O
released	O
on	O
19	O
November	O
2007	O
as	O
part	O
of	O
.NET	O
Framework	O
3.5	O
.	O
</s>
<s>
It	O
includes	O
new	O
features	O
inspired	O
by	O
functional	B-Language
programming	I-Language
languages	I-Language
such	O
as	O
Haskell	B-Language
and	O
ML	B-Language
,	O
and	O
is	O
driven	O
largely	O
by	O
the	O
introduction	O
of	O
the	O
Language	B-Language
Integrated	I-Language
Query	I-Language
(	O
LINQ	B-Language
)	O
pattern	O
to	O
the	O
Common	O
Language	O
Runtime	O
.	O
</s>
<s>
LINQ	B-Language
is	O
a	O
new	O
Microsoft-specific	O
extensible	O
,	O
general-purpose	O
query	O
language	O
for	O
many	O
kinds	O
of	O
data	O
sources	O
—	O
including	O
plain	O
object	O
collections	O
,	O
XML	O
documents	O
,	O
databases	O
,	O
etc.	O
—	O
which	O
is	O
tightly	O
integrated	O
with	O
other	O
C#	B-Application
language	O
facilities	O
.	O
</s>
<s>
The	O
syntax	O
is	O
different	O
from	O
,	O
but	O
borrows	O
from	O
SQL	B-Language
.	O
</s>
<s>
To	O
implement	O
LINQ	B-Language
,	O
a	O
large	O
range	O
of	O
new	O
methods	O
were	O
added	O
to	O
many	O
collections	O
via	O
the	O
System.Linq.Enumerable	O
class	O
.	O
</s>
<s>
LINQ	B-Language
expressions	O
are	O
translated	O
to	O
use	O
these	O
functions	O
before	O
compilation	O
.	O
</s>
<s>
Doing	O
so	O
makes	O
more	O
use	O
of	O
lambda	B-Language
functions	O
,	O
which	O
are	O
discussed	O
below	O
.	O
</s>
<s>
This	O
feature	O
is	O
not	O
just	O
a	O
convenient	O
syntactic	O
sugar	O
for	O
shorter	O
local	O
variable	O
declarations	O
,	O
but	O
it	O
is	O
also	O
required	O
for	O
the	O
declaration	O
of	O
variables	O
of	O
anonymous	B-Language
types	I-Language
.	O
</s>
<s>
Anonymous	B-Language
types	I-Language
provide	O
a	O
convenient	O
way	O
to	O
encapsulate	O
a	O
set	O
of	O
read-only	O
properties	O
into	O
a	O
single	O
object	O
without	O
having	O
to	O
first	O
explicitly	O
define	O
a	O
type	O
.	O
</s>
<s>
Anonymous	B-Language
types	I-Language
are	O
reference	B-Language
types	I-Language
that	O
derive	O
directly	O
from	O
object	O
.	O
</s>
<s>
From	O
the	O
perspective	O
of	O
the	O
common	O
language	O
runtime	O
,	O
an	O
anonymous	B-Language
type	I-Language
is	O
no	O
different	O
from	O
any	O
other	O
reference	B-Language
type	I-Language
,	O
except	O
that	O
it	O
cannot	O
be	O
cast	O
to	O
any	O
type	O
except	O
for	O
object	O
.	O
</s>
<s>
If	O
two	O
or	O
more	O
anonymous	B-Language
types	I-Language
have	O
the	O
same	O
number	O
and	O
type	O
of	O
properties	O
in	O
the	O
same	O
order	O
,	O
the	O
compiler	O
treats	O
them	O
as	O
the	O
same	O
type	O
and	O
they	O
share	O
the	O
same	O
compiler-generated	O
type	O
information	O
.	O
</s>
<s>
Lambda	B-Language
expressions	O
provide	O
a	O
concise	O
way	O
to	O
write	O
first-class	O
anonymous	O
function	O
values	O
.	O
</s>
<s>
Compare	O
the	O
following	O
C#	B-Application
2.0	O
snippet	O
:	O
</s>
<s>
with	O
this	O
C#	B-Application
3.0	O
equivalent	O
:	O
</s>
<s>
In	O
the	O
above	O
examples	O
,	O
lambda	B-Language
expressions	O
are	O
merely	O
shorthand	O
syntax	O
for	O
anonymous	O
delegates	O
with	O
type	O
inference	O
for	O
parameters	O
and	O
return	O
type	O
.	O
</s>
<s>
However	O
,	O
depending	O
on	O
the	O
context	O
they	O
are	O
used	O
in	O
,	O
a	O
C#	B-Application
compiler	O
can	O
also	O
transform	O
lambdas	O
into	O
ASTs	B-Data_Structure
that	O
can	O
then	O
be	O
processed	O
at	O
run-time	O
.	O
</s>
<s>
In	O
the	O
example	O
above	O
,	O
if	O
listOfFoo	O
is	O
not	O
a	O
plain	O
in-memory	O
collection	O
,	O
but	O
a	O
wrapper	O
around	O
a	O
database	O
table	O
,	O
it	O
could	O
use	O
this	O
technique	O
to	O
translate	O
the	O
body	O
of	O
the	O
lambda	B-Language
into	O
the	O
equivalent	O
SQL	B-Language
expression	O
for	O
optimized	O
execution	O
.	O
</s>
<s>
Either	O
way	O
,	O
the	O
lambda	B-Language
expression	O
itself	O
looks	O
exactly	O
the	O
same	O
in	O
the	O
code	O
,	O
so	O
the	O
way	O
it	O
is	O
used	O
at	O
run-time	O
is	O
transparent	O
to	O
the	O
client	O
.	O
</s>
<s>
Expressions	O
,	O
such	O
as	O
x	O
<=	O
y	O
,	O
a	O
=	O
b	O
+	O
c	O
,	O
or	O
even	O
lambda	B-Language
functions	O
and	O
other	O
complex	O
forms	O
can	O
be	O
created	O
dynamically	O
using	O
expression	B-Algorithm
trees	I-Algorithm
.	O
</s>
<s>
Much	O
of	O
the	O
functionality	O
is	O
provided	O
by	O
static	O
methods	O
of	O
the	O
class	O
System.Linq.Expressions.Expression	O
.	O
</s>
<s>
When	O
combined	O
with	O
aspects	O
of	O
the	O
reflection	B-Language
API	I-Language
,	O
this	O
can	O
be	O
a	O
very	O
powerful	O
tool	O
,	O
if	O
a	O
little	O
challenging	O
to	O
write	O
and	O
debug	O
.	O
</s>
