For the complete documentation index, see llms.txt. This page is also available as Markdown.

Null check .any()

You can't just have

if(content.Any())
{
    // Do something
}

The reason is if there is no content then there is nothing to count and do it doesn't exist which means content is equal to null

To combat that you need to null check it.

 @if (content != null && content.Any())
 {
  // do something
 }
  

Last updated