Interesting C# Interview Questions - CodAffection
[the_ad_placement id="before-content"]

Interesting C# Interview Questions

C# Interview Questions

Introduction

In this article, I would like to discuss some of the interesting C# interview questions, This post will be updated with new interesting C# interview questions.

Question and Answer

Q1. Consider the following code snippets

what will be the value of variable i after these two lines?

Ans : 18(5+6+7)
Hint :
i++ will return 5 and then increment to 6
++i will increment 6 to 7 and then return 7

Q2. Maximum dimension allowed in C# araay ?

like a[][][]…[]

Ans : C# array support maximum 32 dimensions. refer this link remark section from msdn.

Q3 . Is it possible to call a c# function without using semicolon?

Usually we call c# function like

Ans: Yes, for c# newbies this might be a tricky question, but it is really simple and you must have done this before.

Semicolon is just to indicate the end of a statement.

Q4. Consider the following snippet

Does it print “Hello World” ? why ?

Ans : No,
Reason :
new bool() returns false
false
 is the default value of bool data type.in c#

will return their default value. you can refer Default Value Table  of all c# datatype from msdn.

Q5. if C# string is a immutable class , consider following code snippet

How many instance will be created for the above code snippet ?

Ans : Only one instance will be created. C# string is a immutable, But it won’t create new instance if the operation does not change it’s value.

For more detailed explanation you can my article on String Vs StringBuider in C#

Q6. Smallest Deployment Unit in .NET?

Ans : Assembly

3 thoughts on “Interesting C# Interview Questions”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
0 Shares
Share via
Copy link
Powered by Social Snap