C# Razor – Conditional Statements

In this chapter you will learn

  • How to use conditional statements inside Razor Syntax?
  • Programming Example

How to use conditional statements inside Razor Syntax?

You can test conditional statement as follow:

If Else Condition

You can use If Else condition inside Razor Syntax as follow:


  • Output

    Oh no. Its Friday

    Switch Case

    You can use switch case statement inside Razor Syntax as follow:

    Output

    It’s Friday

    Summary

    In this chapter you learned to use conditional statement inside Razor Markup. In the next chapter you will learn to use Loop Statement.


    Leave a Reply

    Your email address will not be published. Required fields are marked *