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 2273 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);

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Comment


You might be Interested in these Posts

How to Get the number of elements in ArrayList in C# ?

Here's the code that demonstrates how one can get the total number of elements contained in the Arra...

How to Check if the ArrayList is read-only in C# ?

There are times when you would use the read-only wrapper in order to prevent modifying the ArrayList...

How to Add range of elements to ArrayList in C# ?

You can use the AddRange method of the ArrayList object to add the range of elements (string array) ...