What is the difference between 'int' and 'int?'. For example:
public int? GoalPR { get; set; }
public int AnchorPR { get; set; }
What is the difference between 'int' and 'int?'. For example:
public int? GoalPR { get; set; }
public int AnchorPR { get; set; }
The int? is a nullable type, so the type that can be also null.
The main reason of introduction of this kind of types for value types, is fluent support for
DataBase systems, where value: can be, can be absent and can be null.
There are actually 3 states.
So your code that interacts with the data received and sent to DB smoothly handles that kind of situations having possibility for its own value types assume null value too.
Take a look at the documentation for Nullable<T>.
int? is just syntactic sugar for Nullable<int>
int? can be null.
int can't.
That's (pretty much) the only difference.