Interesting C# Interview Questions


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 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# array ?
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 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

Share this post :

1 Comment

You can post comments in this post.

  • Thank’s Brother . its very conceptual
    please share more conceptual questions

    Nasir shah 3 weeks ago Reply

Post A Reply