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 verbatim string literal in c#?
What is the difference between static and constant variables?
What is different between Static Constructor and Private Constructor?
What is lazy loading c#?
How do I do a case-insensitive string comparison?
What is data types in c#?
What does exclamation mark mean c#?
Can I fly with a loop recorder?
What are boxing and unboxing?
What is difference between code access and role based security?
Can we extend static class in c#?
Can a constructor be private in c#?
What is string class in c#?
Explain the difference between the system.array.copyto() and system.array.clone()?
What's the difference between an integer and int?