Click here to Skip to main content
15,177,535 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello all,

I have some questions related to nullable types:

(0) The advantages and disadvantages of using nullable types?
(1) Why and when I should use a nullable type in my program?

Thank you for your responses.
Posted

Better to look this [^] linkedin discussion
--NDK
   
Comments
wonder-FOOL 8-Dec-11 12:20pm
   
I think the link is broken.
This has a very strong smell of homework, so I'm not going to list any advantages or disadvantages - you can pick those out for your self!

A nullable type can represent the normal range of values for its underlying value type, plus an additional null value. For example, a Nullable Bool can contain true, false, and null. In this case, the null could be used to say "not specified". The ability to assign null to numeric and Boolean types is particularly useful when dealing with databases and other data types containing elements that may not be assigned a value. For example, a Boolean field in a database can store the values true or false, or it may be undefined. If you try to retrieve such a value into a normal bool value, you will get a run time error becasue bool cannot contain null.
   
Comments
wonder-FOOL 8-Dec-11 12:22pm
   
It is not a homework. I was just reviewing a code and in the code there is a nullable int so I asked this question because of my curiousity. But your second paragraph explained me the basic idea about it. Thank you for your answer.
Monjurul Habib 8-Dec-11 15:34pm
   
5!
check this out:

Nullable Types in C#: Basic Introduction[^]

hope it helps :)
   
Comments
Monjurul Habib 8-Dec-11 15:35pm
   
5!
Uday P.Singh 9-Dec-11 0:59am
   
thank you :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900