1

Warning CS8618 Non-nullable property 'Categories_List' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. RazorPageDemoYoutube D:\ASP.NET\RazorPage\RazorPageDemo\RazorPageDemoYoutube\Pages\Admin\Categories\Index.cshtml.cs 16 Active

enter image description here

Qing Guo
  • 6,041
  • 1
  • 2
  • 10
  • In constructor just do Categories_List= new List – D A May 19 '23 at 05:38
  • You can use the `?` suffix to declare a nullable reference type. Try to add `?` ,like `public IEnumerable? Categories_List { get; set; }` . – Qing Guo May 19 '23 at 05:39
  • The Warning includes the answer to your question How to fix: *Consider declaring the property as nullable.* – Sir Rufo May 19 '23 at 05:51

1 Answers1

0

Try to add ? ,like :

public IEnumerable<Category>? Categories_List { get; set; }

OR:

public IEnumerable<Category> Categories_List { get; set; } = new List<Category>();
Qing Guo
  • 6,041
  • 1
  • 2
  • 10