Given the code below, what would output to the Console Window?

Think carefully on this one...it is tricky!
1
string a = ”10”;
2
string b = “20”;
3Console.WriteLine(a+b+5);
C#

35

"10205"

10+20+5

Respuesta :

If you run the code, you can see it will output 10205

Output of the window will be:

"10205"

Explanation:

We can not add String values mathematically because String values can only be used as they are. we have "10" in string a and "20" in string b. We can not add these values so 35 is the wrong answer.  '+'  sign is used for concatenation in c# so 10+20+5 is also the wrong answer.


So Console. Write line (a+b+5) will print "10205" .