In C#, I have a List that has a fixed number of items, 6 to be precise. These are called out in a Razor template, by using a Find(). However, if that Find cannot find the associated list item, it throws a NullReference exception.
The problem is, if an item doesn't exist, then the view won't load.
I need it to instead provide an empty string to the variable.
I've tried:
var video1 = Model.Videos.FirstOrDefault(x => x.VideoType == "Video1") ?? string.Empty;
But this still returns null.
Could anybody help in getting this to work?