can we assign null value to value type in c#?

Answer Posted / ahmad al mursalin

Yes, In C# 2.0 there is introduced one new type called
nullable types. through this we can assign null value in any
value type like...
bool?flag=null;
but before evaluate this value we should check flag value like..
if(!flag.HasValue)
{
flag=true;
}
after that we have to cast bool value to bool like..
if((bool)flag)
{
//write your code.
}

Is This Answer Correct ?    11 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we write system in c#?

489


What is the difference between list and dictionary in c#?

460


How to find type of variable?

545


Is and as keyword in c# net?

529


How do you escape a character?

489






What is difference between array and collection?

471


Why do we need delegates?

497


How do I use the 'using' keyword with multiple objects?

511


Are c# references the same as c++ references?

550


What is bitwise operator in c#?

511


What are the types of parameters in c#?

530


What are satellite assemblies?

559


What are get and set in c#?

582


What is a destructor in c#?

525


Can a struct have a default constructor (a constructor without parameters) or a destructor in c#?

519