Checking if Viewbag property is empty, and using default value in a view

Viewed 18742

I have this piece of code in a MVC view that works, but it seams like a lot of code to achieve this simple thing. Any way to make it more efficient?

@if (string.IsNullOrEmpty(ViewBag.Name))
{
 @:     
}
else
{
 @:ViewBag.Name
}
2 Answers
Related