I have a class (used by filehelpers) which gives me an error when I try to define a nullable string:
public String? ItemNum;
The error is:
Error 1 The type 'string' must be a non-nullable value type in order
to use it as parameter 'T' in the generic type or method 'System.Nullable<T>'
This occurs even with the lowercase string
, though I haven't yet seen a difference between those.
Using another type such as int, decimal etc is fine:
public decimal? ItemNum;
Some general looking on the net talks about defining constructors by field etc, but given the other fields work fine, what's special about string? Is there an elegant way to avoid it?