Tips and Tricks
Cool things you can do with models
@functions
{
// Declare how to render a news item
void RenderContent(NewsItem item)
{
<div>News! @item.Title</div>
}
// Declare how to render a product
void RenderContent(Product item)
{
<div>Product! @product.Name cheap at @product.Price</div>
}
}
@{
RenderContent((dynamic) Model);
}Last updated
Was this helpful?