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
What is the .NET collection class that allows an element to be accessed using a unique key?
What can I create with c#?
Why do we use classes?
What are jump statements in c#?
What is extended class in c#?
Why is static constructor called first?
Are structs value types c#?
What is option parameter in C#?
Why do we need indexers in c#?
What are the types of attributes in c#?
What is deferred execution in c#?
What is the difference between paramaterized constructor and copy constructor?
Why use “using” in c#?
What’s a strong name?
What is private and shared assembly?