what is the nullable integer and where can it be used?
Best Answer
The nullable integer int? or Nullable<int> is a value type in C# whose value can be null or an integer value. It defaults to null instead of 0, and is useful for representing things like value not set (or whatever you want it to represent).
DateTime and TimeSpan are not-nullable since they are structs rather than classes.
As for your second question, there is no standard way you can do this in C#. You can do this using PostSharp, which is an AOP framework, or with Spec#, which is a whole new language (an extension of C#) which allows for some of desired behavior.
Best Answer
The nullable integer
int?
orNullable<int>
is a value type in C# whose value can benull
or an integer value. It defaults tonull
instead of0
, and is useful for representing things likevalue not set
(or whatever you want it to represent).