C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







Nullable DataType in .Net 2.0


Posted Date: 10 Jun 2008    Resource Type: Definitions    Category: General

Posted By: Balasubramaniyam       Member Level: Gold
Rating:     Points: 2



Nullable Data Type



A data type is said to be "nullable" if they can be assigned the value "null". Nullable types are derived from the System.Nullable<T> class. Any nullable object accepts a range of values and also the "null" value.

If you dont have the value for nullable datatype, it will return automatically null as a value.

Example 1:


int? var1 = null;
int? var2 = 5;
var1 = var2;
if (var1.HasValue == true) //Using HasValue properties will will findout "var1" variable having value or null.
{
Response.Write("bala");
}
else
{
Response.Write("bala1");
}



Output:
bala

Let us look at another example:


float? a = 436;
float? b = null;
if (a.HasValue) Response.Write("testing");
if (b.HasValue) Response.Write("testi");
else Response.Write("test");


Output:
testingtest




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Nullable DataType  .  Nullable data type  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: MVC (Model View Controller) pattern
Previous Resource: SQL Injection
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

audio conferencing services

Contact Us    Privacy Policy    Terms Of Use