Home
Search

Start | Blogs | IT | How to do if statements in Razor

2020-06-03

IT

How to do if statements in Razor

Example 1:

<div class="@if(Model.InvertedColor){<text>text-white</text>} content-meta__published_at mb-3x">

 

Example 2:

<div class="@(Model.InvertedColor ? "text-white" : string.Empty) content-meta__published_at mb-3x">