Click here to Skip to main content
15,896,726 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

check this out:

Nullable Types in C#: Basic Introduction[^]

hope it helps :)
 
Share this answer
 
Comments
Monjurul Habib 8-Dec-11 15:35pm    
5!
Uday P.Singh 9-Dec-11 0:59am    
thank you :)
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.
 
Share this answer
 
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!
Better to look this [^] linkedin discussion
--NDK
 
Share this answer
 
Comments
wonder-FOOL 8-Dec-11 12:20pm    
I think the link is broken.

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