C#.NET Interview Questions and Answers – Part 2

Published on April 3, 2015 by abundantcode

Filed under Interview Questions

Last modified April 3, 2015

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 4728 times

C#.NET Interview Questions and Answers – Part 2

11. What are the different type of comments provided by C# for documentation ?

C# supports three different types of comments
– Single Line Comments Eg : //
– Multi Line comments Eg : /* */
– XML Documentation Comments Eg : ///

12. What are the predefined typed in C# ?

The predefined types in C# includes
Value types like Numeric , sbyte, short, int, long , byte, ushort, uint, ulong , float, double, decimal , bool , char.
Reference types like string , object.

13. What are the primitive types in CLR ?

The primitive types in C# are all the value types excluding decimal . The primitive types translates directly to support in the processor that the application is targeted for.

14. What are the various suffixes used for Numeric types in C# ?

F – float
D – double
M – decimal
U – uint
L – long
UL – ulong

15. What is the output of the following code ?

int Input1 = 100000001;
float Float1 = Input1;
int Output1 = (int)Float1;

Answer : 100000000

The reason for this behaviour is that when implicitly converting a large integer number to a floating point number , the precision may sometimes be lost .

16. How to make sure that the arithmetic overflow exception when it happens in C# ?

By default , the when there is a overflow of the data during conversion or assignment , the overflowing happens silently and no exception is thrown. To make sure that there is an arithmetic overflow exception , use the checked operator or checked block.

17. Which are the operator where the checked operator or block doesnot have have any effect on ?

The checked operator does not have any effect on the following datatypes – double , float , decimal.

18. What are the various special values supported by float and double in C# ?

double.NaN  , float.NaN
double.PositiveInfinity , float.PositiveInfinity
double.NegativeInfinity , float.NegativeInfinity
?0.0 , ?0.0f

19. When does the floating value division results in a Infinite value in C# ?

When the floating point number is divided by zero , this results in the infinity value.

Console.WriteLine ( 5.0 / 0.0);

20. When does the result of an operation will be Nan in C# ?

The result will be Nan when we try to divide zero by zero or subtract infinity from infinity.
Console.WriteLine ( 0.0 / 0.0);

Leave a Comment


You might be Interested in these Posts

How to get the AM or PM value from a DateTime object in C# ?

There are times when you might want to get only the string AM or PM from the DateTime object that yo...

C# Program to swap two numbers without using temporary variable

Problem Write a program in Visual CSharp to swap two numbers using temporary variable and display t...

C# Program to print the sum of two numbers

Problem Write a program in C# to add two numbers and display the result in copnsole window. How to...