This is a common type of error we usually face while coding. There are two ways to solve this problem.
Nullable<int> x = null;
int ? x = null;
The above are the two ways to convert a non-nullable value type to nullable value type in C#. A type is said to be nullable if it can be assigned a value or can be assigned null, which means the type has no value whatsoever. By default, all reference types, such as strings, are nullable, but all value types, such as Int32, are not.