what is the syntax of a nullable variable?

 Posted by Nishithraj on 1/22/2010 | Category: C# Interview questions | Views: 3280

Nullable myval=null;

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Raja on: 1/22/2010
Hey Nish,

I do not think this is proper answer of the question. You should have give proper detail about the answer.

IN which language this syntax is used, can you please explain?

Posted by: Utham on: 9/27/2011 | Points: 10
In C# you can write nullable datatype like this:
int? i = null;
DateTime? myDate = null;

Since these int and DateTime datatypes have default values if u dont initialize.. but here you are able to assign null values.

also there are two most useful methods of these nullable types.

//Checks whethe the value is there or not
myDate.GetVaueOrDefualt() --> Get the Value if exists otherwise gives default value of that datatype.

Login to post response