Teste-interpolation-ivan

CSharp · Console

/Program.cs

using System;
using System.Collections.Generic;
                    
public class Program
{
    public static void Main()
    {
        var listaImoveis = new List<Func<Imovel,string>>{
            imovel => $"{imovel.Nome} aqui é meu imóvel",
            imovel => $"{imovel.Numero} aqui é meu imóvel",
            imovel => $"{imovel.Complemento} aqui é meu imóvel"
        };      
        
        var imovelVai = new Imovel { Nome = "Casa X", Numero = "10", Complemento = "Casa X"};       
        foreach(var t in listaImoveis)
            Console.WriteLine(t(imovelVai));
    }
}

public class Imovel
{   
    public string Nome{ get; set; }
    public string Numero{ get; set; }
    public string Complemento{ get; set; } 
}
;