'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:
- add
<Nullable>disable</Nullable>in .csproj file - add
#nullable disablein class - set
Chainaspublic IList<Block> Chain{ get; set; } = new NameOfClassThatImplementsInterface();(recommended) - set
Chainaspublic 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 |
