Lambda expression will not compile
Posted
by John Soer
on Stack Overflow
See other posts from Stack Overflow
or by John Soer
Published on 2010-04-05T16:47:14Z
Indexed on
2010/04/05
17:03 UTC
Read the original article
Hit count: 125
I am very confused.
I have this lamba expression:
tvPatientPrecriptionsEntities.Sort((p1, p2) =>
p1.MedicationStartDate
.Value
.CompareTo(p2.MedicationStartDate.Value));
Visual Studio will not compile it and complains about syntax.
I converted the lamba expression to an anonymous delegate as so:
tvPatientPrecriptionsEntities.Sort(
delegate(PatientPrecriptionsEntity p1, PatientPrecriptionsEntity p2)
{
return p1.MedicationStartDate
.Value
.CompareTo(p2.MedicationStartDate.Value);
});
and it works fine.
The project uses .NET 3.5 and I have a reference to System.Linq
.
© Stack Overflow or respective owner