C# Nullable Solution
Solution 1
We can simply make the properties nullable, as shown below:
public class AppSetting {
public string? ReferenceKey { get; set; }
public string? Value { get; set; }
public string? Description { get; set; }
}
Solution 2
We can assign a default value to those properties as shown below:
public class AppSetting {
public string ReferenceKey { get; set; } = “Default Key”
public string Value { get; set; } = “Default Value”
public string Description { get; set; } = “Default Description”
}
Alternatively, you can give a reasonable default value for non-nullable strings as string.empty.
Solution 3
You can disable this warning from project level. You can disable by removing the below line from project file csproj or setting.
<Nullable>enable</Nullable>