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)
i++ will return 5 and then increment to 6
++i will increment 6 to 7 and then return 7
Ans : C# array support maximum 32 dimensions. refer this link remark section from msdn.
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,
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#
Ans : Assembly