SiteMap  | About    

What is nullable type in c# ?

C# Interview questions and answers

In C# nullable type allow user to assign null value to primitive data types of C# language. These Value types can take either their normal values or a null value. Its default is null meaning you did not assign any value to it. Moreover, a nullable type can represent the correct range of values for its underlying value type, plus an additional null value.

Example of value types are int, float, double, DateTime, etc.

int i = 0; float f = 0; DateTime dToday = DateTime.MinValue;

Can DateTime assigned as null ?

Yes, you can use a nullable DateTime, like this:

DateTime? NullableDateTime;


Nullable<DateTime> NullableDateTime;

More about.....How to DateTime to null ?

What are the types of errors in .Net ?

Error types are fall into one of three categories: syntax errors, run-time errors, and logic errors. interview questions and answersSyntax error (Compilation Errors) : These are errors that prevent your program from running. Most compiler errors are caused by mistakes that you make when typing code. These are the most common type of errors. You can fix them easily in the coding environment as soon as they occur.

Runtime error : These are errors that occur while your program runs. These typically occur when your program attempts an operation that is impossible to carry out.

Logic error :These errors are those that appear once the application is in use. That means, your program may compile and run without error, but the result of an operation may produce a result that you did not expect.

More about.....Difference between Exception and Error

How do you mark a method obsolete ?


.net interview questions and answers

It is better to add an annotation to the method using the keyword Obsolete. The Obsolete attribute can be used without arguments, but including an explanation of why the item is obsolete and what to use instead is recommended.

[Obsolete("Please use Method2")] public void Method1() { }

You can also cause the compilation to fail if the method is called from somewhere in code like this:

[Obsolete("Please use Method2", true)]

More about.....Obsolete or Deprecated in NET Framework (C) 2016    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.