Lamda 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
16:53 UTC
Read the original article
Hit count: 268
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 is uses the .net 3.5 framework and I have a reference to system.linq.
© Stack Overflow or respective owner