Monday, October 3, 2011

Difference between Int32? and Int32 in C#.Net

Int32? allows Null value
Int32 does not allows Null value

Symbol ? indicates that this is a nullable variable

Int32? value = null;
Int32 xyz = (Int32)value;

Error : Nullable object must have a value.

Int32? value = 123;
Int32 xyz = (Int32)value;

No Error.

No comments:

Post a Comment