String interpolation with nameof

var products = new [] {
    new { Name ="Prod1", Price =12M, Category ="Cat1" },
    new { Name = "Prod2", Price = 112M, Category = "Cat2" },
    new { Name = "Prod3", Price = 1112M, Category = "Cat3" },
    new { Name = "Prod4", Price = 111112M, Category = "Cat4" }
};
return View(products.Select(p =>$"{nameof(p.Name)}: {p.Name}, Price: {p.Price}, Category: {p.Category}" ));

Leave a comment