score:5

Accepted answer

this is about lambda syntax, the part on the right is a normal method body that you may shorten when it is 1 expression or 1 statement. otherwise, use full { }and ;

app.uselccors(o => {o.version = "1.0"; o.appid = 2; });

score:1

you probably want to give a lccorsoptions in the initialization of your app. can't you do something like this:

app.uselccors(new lccorsoptions{version = "1.0", appid = 2});

score:3

i'm assuming you're using an extension method that's something like this:

  public static void uselccors(this list<lccorsoptions> list, action<lccorsoptions> action)
    {
        foreach (var item in list)
        {
            action(item);
        }
    }

if so try to put some braces after the lambda sign like this:

app.uselccors(x => { x.version = "1"; x.appid = 1; });

is this what you've been looking for?


Related Query

More Query from same tag