How to assign default value to nullable types? Did nested
nullable types are allowed

Answers were Sorted based on User's Feedback



How to assign default value to nullable types? Did nested nullable types are allowed..

Answer / msg

Here we have two ways to assign a default value.
1. By using Nullcoalsce(??) Operartor
2. by using getvalueordefault() Method.

ex: int? a= null;
int b = a ?? 10;
Or
int b =a.getvalueordefault(); //if null will return zero
or
int b = a. getvalueordefault(10);// if null will retrun 10

--Nested nullable types are NOT Allowed

-By MSG

Is This Answer Correct ?    6 Yes 0 No

How to assign default value to nullable types? Did nested nullable types are allowed..

Answer / msg

Nested nullable types are not allowed. The following line
will not compile:
Nullable<Nullable<int>> n;

- By MSG

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More C Sharp Interview Questions

1. What is IIS. pl explain practically. 2. Difference b/w webserver and application server. pl explain practically.

1 Answers  


Explain the various types of classes used in c#?

0 Answers  


When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)?

2 Answers   Mind Tree,


What is polymorphism in c sharp?

0 Answers  


What is the difference between “constant” and “readonly” variables in c#?

0 Answers  


List down the fundamental oop concepts?

0 Answers  


What is the difference between malloc () and new?

0 Answers  


Why we use delegates in c#?

0 Answers  


What is difference between private, protected, and public in C#?

0 Answers   B-Ways TecnoSoft,


what is the Difference between the public and private ?

0 Answers   Microsoft,


How does the lifecycle of Windows services differ from Standard EXE?

0 Answers   Siebel Systems,


What is the difference between console application and windows application?

0 Answers  


Categories