Possible Duplicate:
What does “DateTime?” mean in C#?
What does the ? mean after a type?
I had a function declaration including a questionmark after the datatype like:
private TimeSpan? sometime()
{
}
What does this mean?
TimeSpan?
is shorthand for System.Nullable<TimeSpan>
.
A TimeSpan
is a value type, which cannot take a null
value. By wrapping it in a System.Nullable<>
it can be null
. Without that ?
it would be illegal to return null
from the function.
Nullable Structure
Represents an object whose underlying type is a value type that can also be assigned null like a reference type.
Instead of writing Nullable<TimeSpan>
, you can write TimeSpan?
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With