I'm trying to understand writing anonymous Methods in C#. But having trouble to achieve a success.
Please have a look at my example. I'm trying to fill a property named Value by given conditions.
When I would write a private helper method which takes an inputparam int lockCardStatus and returns a string that would be a solution but my intention is to try this with a "quickshot" like so:
MailMessageTextPlaceholders = new List<MailMessageTextPlaceholder>
{
new MailMessageTextPlaceholder
{
PlaceholderName = "status",
Value = y =>
{
switch (_lockCard.Status)
{
case (int)LockCard.LockCardStatus.Done :
return "Is Done";
case (int)LockCard.LockCardStatus.Pending :
return "Is in Pending status";
case (int)LockCard.LockCardStatus.Open :
return "Has been created";
default:
return "No status yet!";
}
}
}
}
Unfortunately the compiler says:
Lambda Expression cannot be converted to type string because it is not a delgate.