Jay Croghan
Jay Croghan

Reputation: 482

Convert delegate to lambda?

My coding standards plugin is complaining and telling me to use a lambda for this delegate but the only suggested fix is to ignore the warning, how do I go about this?

myobb.Populate += delegate(string s1, string s2)
{
    string s3 = s1 + s2;
    SomeObject.DoSomething(s3);
};

Upvotes: 2

Views: 178

Answers (1)

mtanksl
mtanksl

Reputation: 591

Like so:

myobb.Populate += (string s1, string s2) =>
{

};

or simpler:

myobb.Populate += (s1, s2) =>
{

};

Upvotes: 4

Related Questions