Created
May 11, 2021 16:38
-
-
Save luisdeol/79893c2b179a22a5a8593b7361f66407 to your computer and use it in GitHub Desktop.
Artigo LINQ #2: Select
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace ArtigoLinq | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var pessoas = new List<Pessoa> | |
{ | |
new Pessoa("Luis", "Dev", "123.456.789-10", "Rua Numero 1", "00000-000", "123a", "São Paulo/SP"), | |
new Pessoa("Rafael", "Dev", "321.654.987-99", "Rua Numero 1", "00000-000", "123b", "São Paulo/SP"), | |
new Pessoa("Nicholas", "Dev", "789.456.123-65", "Rua Numero 1", "00000-000", "123c", "São Paulo/SP") | |
}; | |
var pessoasViewModel = pessoas | |
.Select(p => new PessoaItemViewModel( | |
$"{p.Nome} {p.Sobrenome}", | |
p.Documento | |
)) | |
.ToList(); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment