Can DateTime be assigned null ?

 Posted by Ddd on 2/11/2011 | Category: C# Interview questions | Views: 4231 | Points: 40

Yes we can assign null to a variable of DateTime datatype

For ex :
.Consider this snippet

class A

static void Main()
DateTime? a=null;

//Compile it and execute:

//DateTime is a nullable data type(it is a value type) whose variable can be assigned null values when declared with ? sign.
In the output, we shall see the string value concatenated with blank string

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response