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

What does dbml mean?

511


Why to use lock statement in c#?

501


What are c# collections?

482


What is a datacontract?

490


Is it possible to restrict the scope of a field/method of a class to the classes in the same namespace?

511






What is the advantage of constructor?

487


What is the difference between finalize() and dispose() methods?

546


What is int tryparse in c#?

530


What's new in c#?

497


Can abstract class be sealed?

490


What is ado c#?

544


What is sorting in c#?

525


How do I open the console window?

581


How to reverse each word in a string using c#?

569


Expalin the way you implement inheritance by using VB.NET/C#?

536