Switch case conditional operator in ASP.NET MVC

How to perform switch case conditional operation in view?

It is similar to if, we just need to write switch statement. Notice how beautifully we are able to mix the C# and HTML code. 
@switch (fileName) 
{ 
 case "itfunda": 
 <p>itfunda logo</p> 
 break; 
 case "dotnetfunda": 
 <p>dotnetfunda logo</p> 
 break; 
 default : 
 <p>no logo</p> 
 break;
 }

No comments:

Post a Comment

How to register multiple implementations of the same interface in Asp.Net Core?

 Problem: I have services that are derived from the same interface. public interface IService { } public class ServiceA : IService { ...