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

What is console programming language?

0 Answers  


What is xml comments in c#?

0 Answers  


what is the difference between .dll and .exe

0 Answers   HCL,


What is boolean method?

0 Answers  


What is called method in c#?

0 Answers  






What is the wildcard character in SQL? Let?s say you want to query database with LIKE for all employees whose name starts with La.

1 Answers  


can u tell me any one steps for creatting sn.k

2 Answers  


What is the name of c# compiler?

0 Answers  


What is yield c#?

0 Answers  


What is the difference between inheritance and abstract class?

0 Answers  


Write a console application and implement the ternary operator to decide whether the age a user entered after being prompted is allowed to vote or not(given that only citizens between 18 and 120 years only inclusive can vote). Use exception handling for non-numerical input.

0 Answers  


What is difference between string and stringbuilder in c#?

0 Answers  


Categories