'how i can fix following nullrefernce ? and also how can I turn off nullrefernce (from <propertygroup>)?

public class BlockChain
{   
   public IList<Block>Chain{ get; set; }
}

Non-nullable property 'Chain' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.



Solution 1:[1]

Not sure what project you are writing but you could do:

  1. add <Nullable>disable</Nullable> in .csproj file
  2. add #nullable disable in class
  3. set Chain as public IList<Block> Chain{ get; set; } = new NameOfClassThatImplementsInterface(); (recommended)
  4. set Chain as public IList<Block>? Chain{ get; set; }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1