mercredi 14 mars 2018

Return a select linq directly or assign a value to a variable before

What this makes more sense and are more readable? Return a select linq directly or assign a value to a variable before?

    public dynamic Names(List<Person> persons)
    {
        var output = persons.Select(x => new
        {
           Name = x.Name
        }).ToList();

        return output;
    }

Or this?

    public dynamic Names(List<Person> persons)
    {
        return persons.Select(x => new
        {
           Name = x.Name
        }).ToList();
    }

Aucun commentaire:

Enregistrer un commentaire